Changeset 15bc063


Ignore:
Timestamp:
2011-03-29T22:47:00Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
6220254
Parents:
4f50ea5
Message:

Also use the short IDs for a new reply command. Couldn't think of a sane way
to support "xx:" or "@xx" since it would also become too ambiguous. Only
thing left to do now is documenting it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter.c

    r4f50ea5 r15bc063  
    454454{
    455455        struct twitter_data *td = ic->proto_data;
    456         char *cmds, **cmd;
     456        char *cmds, **cmd, *new = NULL;
     457        guint64 in_reply_to = 0;
    457458       
    458459        cmds = g_strdup( message );
     
    524525                return;
    525526        }
     527        else if( g_strcasecmp( cmd[0], "reply" ) == 0 && cmd[1] && cmd[2] )
     528        {
     529                struct twitter_user_data *tud;
     530                bee_user_t *bu = NULL;
     531                guint64 id = 0;
     532               
     533                if( ( bu = bee_user_by_handle( ic->bee, ic, cmd[1] ) ) &&
     534                    ( tud = bu->data ) && tud->last_id )
     535                {
     536                        id = tud->last_id;
     537                }
     538                else if( ( id = g_ascii_strtoull( cmd[1], NULL, 10 ) ) &&
     539                         ( id < TWITTER_LOG_LENGTH ) )
     540                {
     541                        bu = td->log[id].bu;
     542                        if( g_slist_find( ic->bee->users, bu ) )
     543                                id = td->log[id].id;
     544                        else
     545                                bu = NULL;
     546                }
     547                if( !id || !bu )
     548                {
     549                        twitter_msg( ic, "User `%s' does not exist or didn't "
     550                                         "post any statuses recently", cmd[1] );
     551                        return;
     552                }
     553                message = new = g_strdup_printf( "@%s %s", bu->handle,
     554                                                 message + ( cmd[2] - cmd[0] ) );
     555                in_reply_to = id;
     556        }
    526557        else if( g_strcasecmp( cmd[0], "post" ) == 0 )
    527558        {
     
    530561       
    531562        {
    532                 guint64 in_reply_to = 0;
    533                 char *s, *new = NULL;
     563                char *s;
    534564                bee_user_t *bu;
    535565               
    536566                if( !twitter_length_check( ic, message ) )
    537567                {
     568                        g_free( new );
    538569                        g_free( cmds );
    539570                        return;
     
    541572               
    542573                s = cmd[0] + strlen( cmd[0] ) - 1;
    543                 if( s > cmd[0] && ( *s == ':' || *s == ',' ) )
     574                if( !new && s > cmd[0] && ( *s == ':' || *s == ',' ) )
    544575                {
    545576                        *s = '\0';
Note: See TracChangeset for help on using the changeset viewer.