Ignore:
Timestamp:
2010-04-15T23:10:10Z (10 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
55b1e69
Parents:
f9ed311
Message:

Added a meta-contact twitter_$username and replaced the "use_groupchat"
setting with a "mode" setting which also allows for a mode where everything
just comes from the meta-contact. Tweets should now go to that user or to
the channel (if available). Messages to others become DMs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter_lib.c

    rf9ed311 re88fbe27  
    105105        if (!imcb_find_buddy( ic, name ))
    106106        {
     107                char *mode = set_getstr(&ic->acc->set, "mode");
     108               
    107109                // The buddy is not in the list, add the buddy and set the status to logged in.
    108110                imcb_add_buddy( ic, name, NULL );
    109111                imcb_rename_buddy( ic, name, fullname );
    110                 if (set_getbool( &ic->acc->set, "use_groupchat" ))
     112                if (g_strcasecmp(mode, "chat") == 0)
    111113                        imcb_chat_add_buddy( td->home_timeline_gc, name );
    112                 else
     114                else if (g_strcasecmp(mode, "many") == 0)
    113115                        imcb_buddy_status( ic, name, OPT_LOGGED_IN, NULL, NULL );
    114116        }
     
    452454        GSList *l = NULL;
    453455        struct twitter_xml_status *status;
    454 
     456        char from[MAX_STRING];
     457        gboolean mode_one;
     458       
     459        mode_one = g_strcasecmp( set_getstr( &ic->acc->set, "mode" ), "one" ) == 0;
     460
     461        if( mode_one )
     462        {
     463                g_snprintf( from, sizeof( from ) - 1, "twitter_%s", ic->acc->user );
     464                from[MAX_STRING-1] = '\0';
     465        }
     466       
    455467        for ( l = list; l ; l = g_slist_next(l) )
    456468        {
     469                char *text = NULL;
     470               
    457471                status = l->data;
    458                 imcb_buddy_msg( ic, status->user->screen_name, status->text, 0, status->created_at );
     472               
     473                if( mode_one )
     474                        text = g_strdup_printf( "\002<\002%s\002>\002 %s",
     475                                                status->user->screen_name, status->text );
     476               
     477                imcb_buddy_msg( ic,
     478                                mode_one ? from : status->user->screen_name,
     479                                mode_one ? text : status->text,
     480                                0, status->created_at );
     481               
    459482                // Update the home_timeline_id to hold the highest id, so that by the next request
    460483                // we won't pick up the updates allready in the list.
    461484                td->home_timeline_id = td->home_timeline_id < status->id ? status->id : td->home_timeline_id;
     485               
     486                g_free( text );
    462487        }
    463488}
     
    512537
    513538        // See if the user wants to see the messages in a groupchat window or as private messages.
    514         if (set_getbool( &ic->acc->set, "use_groupchat" ))
     539        if (g_strcasecmp(set_getstr(&ic->acc->set, "mode"), "chat") == 0)
    515540                twitter_groupchat(ic, txl->list);
    516541        else
     
    612637        if (req->status_code != 200) {
    613638                // It didn't go well, output the error and return.
    614                 imcb_error(ic, "Could not post tweet... HTTP STATUS: %d", req->status_code);
     639                imcb_error(ic, "Could not post message... HTTP STATUS: %d", req->status_code);
    615640                return;
    616641        }
Note: See TracChangeset for help on using the changeset viewer.