diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2015-05-04 23:21:57 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2015-05-04 23:21:57 +0200 |
commit | 5ca141685d78cb372acd0e9aded36175cba957a3 (patch) | |
tree | e18b13d32ecc35ea1bac07a2ca794a4cfb378ef8 /protocols/twitter/twitter.c | |
parent | 70ec7ab33202b933a88e04122140a815a7d2081e (diff) | |
parent | c43146d9308aea2025c0a0520c9e2d40758d9e8d (diff) |
Merge branch 'wilmer-twitter'
Diffstat (limited to 'protocols/twitter/twitter.c')
-rw-r--r-- | protocols/twitter/twitter.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 95384573..421a0552 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -866,6 +866,8 @@ static gboolean twitter_parse_id(char *string, int base, guint64 *id) return TRUE; } +bee_user_t twitter_log_local_user; + /** Convert the given bitlbee tweet ID, bitlbee username, or twitter tweet ID * into a twitter tweet ID. * @@ -896,10 +898,6 @@ static guint64 twitter_message_id_from_command_arg(struct im_connection *ic, cha if (twitter_parse_id(arg, 16, &id) && id < TWITTER_LOG_LENGTH) { bu = td->log[id].bu; id = td->log[id].id; - /* Beware of dangling pointers! */ - if (!g_slist_find(ic->bee->users, bu)) { - bu = NULL; - } } else if (twitter_parse_id(arg, 10, &id)) { /* Allow normal tweet IDs as well; not a very useful feature but it's always been there. Just ignore @@ -910,6 +908,16 @@ static guint64 twitter_message_id_from_command_arg(struct im_connection *ic, cha } } if (bu_) { + if (bu == &twitter_log_local_user) { + /* HACK alert. There's no bee_user object for the local + * user so just fake one for the few cmds that need it. */ + twitter_log_local_user.handle = td->user; + } else { + /* Beware of dangling pointers! */ + if (!g_slist_find(ic->bee->users, bu)) { + bu = NULL; + } + } *bu_ = bu; } return id; @@ -1002,6 +1010,19 @@ static void twitter_handle_command(struct im_connection *ic, char *message) message = cmd[2]; in_reply_to = id; allow_post = TRUE; + } else if (g_strcasecmp(cmd[0], "url") == 0) { + id = twitter_message_id_from_command_arg(ic, cmd[1], &bu); + if (!id) { + twitter_log(ic, "Tweet `%s' does not exist", cmd[1]); + } else { + /* More common link is twitter.com/$UID/status/$ID (and that's + * what this will 302 to) but can't generate that since for RTs, + * bu here points at the retweeter while id contains the id of + * the original message. */ + twitter_log(ic, "https://twitter.com/statuses/%lld", id); + } + goto eof; + } else if (g_strcasecmp(cmd[0], "post") == 0) { message += 5; allow_post = TRUE; |