Changeset e88fbe27 for protocols/twitter
- Timestamp:
- 2010-04-15T23:10:10Z (15 years ago)
- Branches:
- master
- Children:
- 55b1e69
- Parents:
- f9ed311
- Location:
- protocols/twitter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter.c
rf9ed311 re88fbe27 41 41 // If the user uses multiple private message windows we need to get the 42 42 // users buddies. 43 if ( !set_getbool( &ic->acc->set, "use_groupchat" ))43 if (g_strcasecmp(set_getstr(&ic->acc->set, "mode"), "many") == 0) 44 44 twitter_get_statuses_friends(ic, -1); 45 45 … … 51 51 } 52 52 53 static 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 } 53 62 54 63 static void twitter_init( account_t *acc ) 55 64 { 56 65 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 ); 58 68 s->flags |= ACC_SET_OFFLINE_ONLY; 59 69 } … … 67 77 struct im_connection *ic = imcb_new( acc ); 68 78 struct twitter_data *td = g_new0( struct twitter_data, 1 ); 79 char name[strlen(acc->user)+9]; 69 80 70 81 twitter_connections = g_slist_append( twitter_connections, ic ); … … 84 95 // Save the return value, so we can remove the timeout on logout. 85 96 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 ); 86 101 } 87 102 … … 115 130 static int twitter_buddy_msg( struct im_connection *ic, char *who, char *message, int away ) 116 131 { 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) 119 134 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 122 138 return( 0 ); 123 139 } -
protocols/twitter/twitter_lib.c
rf9ed311 re88fbe27 105 105 if (!imcb_find_buddy( ic, name )) 106 106 { 107 char *mode = set_getstr(&ic->acc->set, "mode"); 108 107 109 // The buddy is not in the list, add the buddy and set the status to logged in. 108 110 imcb_add_buddy( ic, name, NULL ); 109 111 imcb_rename_buddy( ic, name, fullname ); 110 if ( set_getbool( &ic->acc->set, "use_groupchat" ))112 if (g_strcasecmp(mode, "chat") == 0) 111 113 imcb_chat_add_buddy( td->home_timeline_gc, name ); 112 else 114 else if (g_strcasecmp(mode, "many") == 0) 113 115 imcb_buddy_status( ic, name, OPT_LOGGED_IN, NULL, NULL ); 114 116 } … … 452 454 GSList *l = NULL; 453 455 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 455 467 for ( l = list; l ; l = g_slist_next(l) ) 456 468 { 469 char *text = NULL; 470 457 471 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 459 482 // Update the home_timeline_id to hold the highest id, so that by the next request 460 483 // we won't pick up the updates allready in the list. 461 484 td->home_timeline_id = td->home_timeline_id < status->id ? status->id : td->home_timeline_id; 485 486 g_free( text ); 462 487 } 463 488 } … … 512 537 513 538 // 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) 515 540 twitter_groupchat(ic, txl->list); 516 541 else … … 612 637 if (req->status_code != 200) { 613 638 // 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); 615 640 return; 616 641 }
Note: See TracChangeset
for help on using the changeset viewer.