- Timestamp:
- 2010-08-08T13:42:57Z (14 years ago)
- Branches:
- master
- Children:
- 2528cda, f32c14c
- Parents:
- 203a2d2
- Location:
- protocols/twitter
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter.c
r203a2d2 rb890626 186 186 } 187 187 188 s = set_add( &acc->set, "auto_reply_timeout", "10800", set_eval_int, acc ); 189 188 190 s = set_add( &acc->set, "base_url", def_url, NULL, acc ); 189 191 s->flags |= ACC_SET_OFFLINE_ONLY; … … 427 429 428 430 if( cmd[1] ) 429 { 430 char *end = NULL; 431 432 id = g_ascii_strtoull( cmd[1], &end, 10 ); 433 if( end == NULL ) 434 id = 0; 435 } 431 id = g_ascii_strtoull( cmd[1], NULL, 10 ); 436 432 else 437 433 id = td->last_status_id; … … 444 440 return; 445 441 } 442 else if( g_strcasecmp( cmd[0], "follow" ) == 0 && cmd[1] ) 443 { 444 twitter_add_buddy( ic, cmd[1], NULL ); 445 g_free( cmds ); 446 return; 447 } 448 else if( g_strcasecmp( cmd[0], "unfollow" ) == 0 && cmd[1] ) 449 { 450 twitter_remove_buddy( ic, cmd[1], NULL ); 451 g_free( cmds ); 452 return; 453 } 454 else if( g_strcasecmp( cmd[0], "rt" ) == 0 && cmd[1] ) 455 { 456 struct twitter_user_data *tud; 457 bee_user_t *bu; 458 guint64 id; 459 460 if( ( bu = bee_user_by_handle( ic->bee, ic, cmd[1] ) ) && 461 ( tud = bu->data ) && tud->last_id ) 462 id = tud->last_id; 463 else 464 id = g_ascii_strtoull( cmd[1], NULL, 10 ); 465 466 td->last_status_id = 0; 467 if( id ) 468 twitter_status_retweet( ic, id ); 469 470 g_free( cmds ); 471 return; 472 } 446 473 else if( g_strcasecmp( cmd[0], "post" ) == 0 ) 447 474 { … … 450 477 451 478 { 479 guint64 in_reply_to = 0; 452 480 char *s, *new = NULL; 453 481 bee_user_t *bu; … … 466 494 if( ( bu = bee_user_by_handle( ic->bee, ic, cmd[0] ) ) ) 467 495 { 496 struct twitter_user_data *tud = bu->data; 497 468 498 new = g_strdup_printf( "@%s %s", bu->handle, 469 499 message + ( s - cmd[0] ) + 2 ); 470 500 message = new; 501 502 if( time( NULL ) < tud->last_time + 503 set_getint( &ic->acc->set, "auto_reply_timeout" ) ) 504 in_reply_to = tud->last_id; 471 505 } 472 506 } 473 507 474 twitter_post_status( ic, message ); 508 /* If the user runs undo between this request and its response 509 this would delete the second-last Tweet. Prevent that. */ 510 td->last_status_id = 0; 511 twitter_post_status( ic, message, in_reply_to ); 475 512 g_free( new ); 476 513 } -
protocols/twitter/twitter_lib.c
r203a2d2 rb890626 784 784 * Function to POST a new status to twitter. 785 785 */ 786 void twitter_post_status(struct im_connection *ic, char* msg) 787 { 788 char* args[2]; 789 args[0] = "status"; 790 args[1] = msg; 791 twitter_http(ic, TWITTER_STATUS_UPDATE_URL, twitter_http_post, ic, 1, args, 2); 792 // g_free(args[1]); 786 void twitter_post_status(struct im_connection *ic, char *msg, guint64 in_reply_to) 787 { 788 char* args[4] = { 789 "status", msg, 790 "in_reply_to_status_id", 791 g_strdup_printf("%llu", (unsigned long long) in_reply_to) 792 }; 793 twitter_http(ic, TWITTER_STATUS_UPDATE_URL, twitter_http_post, ic, 1, 794 args, in_reply_to ? 4 : 2); 795 g_free(args[3]); 793 796 } 794 797 … … 825 828 g_free(url); 826 829 } 830 831 void twitter_status_retweet(struct im_connection *ic, guint64 id) 832 { 833 char *url; 834 url = g_strdup_printf("%s%llu%s", TWITTER_STATUS_RETWEET_URL, (unsigned long long) id, ".xml"); 835 twitter_http(ic, url, twitter_http_post, ic, 1, NULL, 0); 836 g_free(url); 837 } -
protocols/twitter/twitter_lib.h
r203a2d2 rb890626 36 36 #define TWITTER_STATUS_SHOW_URL "/statuses/show/" 37 37 #define TWITTER_STATUS_DESTROY_URL "/statuses/destroy/" 38 #define TWITTER_STATUS_RETWEET_URL "/statuses/retweet/" 38 39 39 40 /* Timeline URLs */ … … 81 82 void twitter_get_statuses_friends(struct im_connection *ic, gint64 next_cursor); 82 83 83 void twitter_post_status(struct im_connection *ic, char *msg );84 void twitter_post_status(struct im_connection *ic, char *msg, guint64 in_reply_to); 84 85 void twitter_direct_messages_new(struct im_connection *ic, char *who, char *message); 85 86 void twitter_friendships_create_destroy(struct im_connection *ic, char *who, int create); 86 87 void twitter_status_destroy(struct im_connection *ic, guint64 id); 88 void twitter_status_retweet(struct im_connection *ic, guint64 id); 87 89 88 90 #endif //_TWITTER_LIB_H
Note: See TracChangeset
for help on using the changeset viewer.