Changeset b890626
- Timestamp:
- 2010-08-08T13:42:57Z (14 years ago)
- Branches:
- master
- Children:
- 2528cda, f32c14c
- Parents:
- 203a2d2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/user-guide/commands.xml
r203a2d2 rb890626 495 495 </bitlbee-setting> 496 496 497 <bitlbee-setting name="auto_reply_timeout" type="integer" scope="account"> 498 <default>10800</default> 499 500 <description> 501 <para> 502 For Twitter accounts: If you respond to Tweets IRC-style (like "nickname: reply"), this will automatically be converted to the usual Twitter format ("@screenname reply"). 503 </para> 504 505 <para> 506 By default, BitlBee will then also add a reference to that person's most recent Tweet, unless that message is older than the value of this setting in seconds. 507 </para> 508 509 <para> 510 If you want to disable this feature, just set this to 0. Alternatively, if you want to write a message once that is <emphasis>not</emphasis> a reply, use the Twitter reply syntax (@screenname). 511 </para> 512 </description> 513 </bitlbee-setting> 514 497 515 <bitlbee-setting name="away" type="string" scope="both"> 498 516 <description> … … 598 616 <para> 599 617 For setting up named chatrooms, it's currently easier to just use the <emphasis>chat add</emphasis> command. 618 </para> 619 </description> 620 </bitlbee-setting> 621 622 <bitlbee-setting name="commands" type="boolean" scope="account"> 623 <default>true</default> 624 625 <description> 626 <para> 627 With this setting enabled, you can use some commands in your Twitter channel/query. The commands are simple and not documented in too much detail: 628 </para> 629 630 <variablelist> 631 <varlistentry><term>undo [<id>]</term><listitem><para>Delete your last Tweet (or one with the given ID)</para></listitem></varlistentry> 632 <varlistentry><term>rt <screenname|id></term><listitem><para>Retweet someone's last Tweet (or one with the given ID)</para></listitem></varlistentry> 633 <varlistentry><term>follow <screenname></term><listitem><para>Start following a person</para></listitem></varlistentry> 634 <varlistentry><term>unfollow <screenname></term><listitem><para>Stop following a person</para></listitem></varlistentry> 635 <varlistentry><term>post <message></term><listitem><para>Post a tweet</para></listitem></varlistentry> 636 </variablelist> 637 638 <para> 639 Anything that doesn't look like a command will be treated as a tweet. Watch out for typos! :-) 600 640 </para> 601 641 </description> -
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.