Changeset b8c336b for protocols/twitter/twitter.c
- Timestamp:
- 2015-05-09T19:50:30Z (10 years ago)
- Children:
- ec8b369
- Parents:
- 356e2dd (diff), 5014380 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter.c
r356e2dd rb8c336b 483 483 } 484 484 485 static gboolean twitter_length_check(struct im_connection *ic, gchar * msg) 486 { 487 int max = set_getint(&ic->acc->set, "message_length"), len; 488 int target_len = set_getint(&ic->acc->set, "target_url_length"); 485 int twitter_message_len(gchar *msg, int target_len) 486 { 489 487 int url_len_diff = 0; 490 488 … … 493 491 } 494 492 495 if (max == 0 || (len = g_utf8_strlen(msg, -1) + url_len_diff) <= max) { 493 return g_utf8_strlen(msg, -1) + url_len_diff; 494 } 495 496 static gboolean twitter_length_check(struct im_connection *ic, gchar * msg) 497 { 498 int max = set_getint(&ic->acc->set, "message_length"); 499 int target_len = set_getint(&ic->acc->set, "target_url_length"); 500 int len = twitter_message_len(msg, target_len); 501 502 if (max == 0 || len <= max) { 496 503 return TRUE; 497 504 } … … 867 874 } 868 875 876 bee_user_t twitter_log_local_user; 877 869 878 /** Convert the given bitlbee tweet ID, bitlbee username, or twitter tweet ID 870 879 * into a twitter tweet ID. … … 897 906 bu = td->log[id].bu; 898 907 id = td->log[id].id; 899 /* Beware of dangling pointers! */900 if (!g_slist_find(ic->bee->users, bu)) {901 bu = NULL;902 }903 908 } else if (twitter_parse_id(arg, 10, &id)) { 904 909 /* Allow normal tweet IDs as well; not a very useful … … 911 916 } 912 917 if (bu_) { 918 if (bu == &twitter_log_local_user) { 919 /* HACK alert. There's no bee_user object for the local 920 * user so just fake one for the few cmds that need it. */ 921 twitter_log_local_user.handle = td->user; 922 } else { 923 /* Beware of dangling pointers! */ 924 if (!g_slist_find(ic->bee->users, bu)) { 925 bu = NULL; 926 } 927 } 913 928 *bu_ = bu; 914 929 } … … 1003 1018 in_reply_to = id; 1004 1019 allow_post = TRUE; 1020 } else if (g_strcasecmp(cmd[0], "url") == 0) { 1021 id = twitter_message_id_from_command_arg(ic, cmd[1], &bu); 1022 if (!id) { 1023 twitter_log(ic, "Tweet `%s' does not exist", cmd[1]); 1024 } else { 1025 /* More common link is twitter.com/$UID/status/$ID (and that's 1026 * what this will 302 to) but can't generate that since for RTs, 1027 * bu here points at the retweeter while id contains the id of 1028 * the original message. */ 1029 twitter_log(ic, "https://twitter.com/statuses/%lld", id); 1030 } 1031 goto eof; 1032 1005 1033 } else if (g_strcasecmp(cmd[0], "post") == 0) { 1006 1034 message += 5;
Note: See TracChangeset
for help on using the changeset viewer.