aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2015-05-02 23:03:35 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2015-05-02 23:03:35 +0200
commit9ed817598e0f46b786ab988098ea25294a53e151 (patch)
tree3ce82d388c657f7549f9b240a69c1a5d0626f2c9
parent40cfbc54088702d4887ccfb761eafe65b4376d59 (diff)
Add "url" command to Twitter module to get web URL for a Tweet.
-rw-r--r--doc/user-guide/commands.xml3
-rw-r--r--protocols/twitter/twitter.c13
2 files changed, 15 insertions, 1 deletions
diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml
index 6ce19774..4d6e7659 100644
--- a/doc/user-guide/commands.xml
+++ b/doc/user-guide/commands.xml
@@ -120,7 +120,7 @@
<description>
<para>
- This commands deletes an account from your account list. You should signoff the account before deleting it.
+ This command deletes an account from your account list. You should signoff the account before deleting it.
</para>
@@ -852,6 +852,7 @@
<varlistentry><term>unfollow &lt;screenname&gt;</term><listitem><para>Stop following a person</para></listitem></varlistentry>
<varlistentry><term>favourite &lt;screenname|#id&gt;</term><listitem><para>Favo<emphasis>u</emphasis>rite the given user's most recent tweet, or the given tweet ID.</para></listitem></varlistentry>
<varlistentry><term>post &lt;message&gt;</term><listitem><para>Post a tweet</para></listitem></varlistentry>
+ <varlistentry><term>url &lt;screenname|#id&gt;</term><listitem><para>Show URL for a tweet to open it in a browser (and see context)</para></listitem></varlistentry>
</variablelist>
<para>
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c
index 95384573..4dc1785e 100644
--- a/protocols/twitter/twitter.c
+++ b/protocols/twitter/twitter.c
@@ -1002,6 +1002,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;