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.c

    rf9ed311 re88fbe27  
    4141        // If the user uses multiple private message windows we need to get the
    4242        // users buddies.
    43         if (!set_getbool( &ic->acc->set, "use_groupchat" ))
     43        if (g_strcasecmp(set_getstr(&ic->acc->set, "mode"), "many") == 0)
    4444                twitter_get_statuses_friends(ic, -1);
    4545
     
    5151}
    5252
     53static char *set_eval_mode( set_t *set, char *value )
     54{
     55        if( g_strcasecmp( value, "one" ) == 0 ||
     56            g_strcasecmp( value, "many" ) == 0 ||
     57            g_strcasecmp( value, "char" ) == 0 )
     58                return value;
     59        else
     60                return NULL;
     61}
    5362
    5463static void twitter_init( account_t *acc )
    5564{
    5665        set_t *s;
    57         s = set_add( &acc->set, "use_groupchat", "false", set_eval_bool, acc );
     66       
     67        s = set_add( &acc->set, "mode", "one", set_eval_mode, acc );
    5868        s->flags |= ACC_SET_OFFLINE_ONLY;
    5969}
     
    6777        struct im_connection *ic = imcb_new( acc );
    6878        struct twitter_data *td = g_new0( struct twitter_data, 1 );
     79        char name[strlen(acc->user)+9];
    6980
    7081        twitter_connections = g_slist_append( twitter_connections, ic );
     
    8495        // Save the return value, so we can remove the timeout on logout.
    8596        td->main_loop_id = b_timeout_add(60000, twitter_main_loop, ic);
     97       
     98        sprintf( name, "twitter_%s", acc->user );
     99        imcb_add_buddy( ic, name, NULL );
     100        imcb_buddy_status( ic, name, OPT_LOGGED_IN, NULL, NULL );
    86101}
    87102
     
    115130static int twitter_buddy_msg( struct im_connection *ic, char *who, char *message, int away )
    116131{
    117         // Let's just update the status.
    118 //      if ( g_strcasecmp(who, ic->acc->user) == 0 )
     132        if (g_strncasecmp(who, "twitter_", 8) == 0 &&
     133            g_strcasecmp(who + 8, ic->acc->user) == 0)
    119134                twitter_post_status(ic, message);
    120 //      else
    121 //              twitter_direct_messages_new(ic, who, message);
     135        else
     136                twitter_direct_messages_new(ic, who, message);
     137       
    122138        return( 0 );
    123139}
Note: See TracChangeset for help on using the changeset viewer.