Changeset b8b931d


Ignore:
Timestamp:
2020-05-07T19:33:52Z (4 weeks ago)
Author:
GitHub <noreply@…>
Branches:
master
Parents:
3da21ce
git-author:
Iguana <kathy@…> (07-05-20 19:33:52)
git-committer:
GitHub <noreply@…> (07-05-20 19:33:52)
Message:

Add support for group reply using auto_populate_reply_metadata (#146)

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • doc/user-guide/twitter.xml

    r3da21ce rb8b931d  
    1515<varlistentry><term>undo [&lt;#id&gt;]</term><listitem><para>Delete your last message (or one with the given ID)</para></listitem></varlistentry>
    1616<varlistentry><term>rt &lt;screenname|#id&gt;</term><listitem><para>Retweet someone's last message (or one with the given ID)</para></listitem></varlistentry>
    17 <varlistentry><term>reply &lt;screenname|#id&gt;</term><listitem><para>Reply to a message (with a reply-to reference)</para></listitem></varlistentry>
     17<varlistentry><term>reply &lt;screenname|#id&gt;</term><listitem><para>Reply to a message (with a reply-to reference, mentions only one user)</para></listitem></varlistentry>
    1818<varlistentry><term>rawreply &lt;screenname|#id&gt;</term><listitem><para>Reply to a message (with no reply-to reference)</para></listitem></varlistentry>
     19<varlistentry><term>greply &lt;screenname|#id&gt;</term><listitem><para>Group reply to a message (with reply-to, mentions every user in the conversation)</para></listitem></varlistentry>
    1920<varlistentry><term>report &lt;screenname|#id&gt;</term><listitem><para>Report the given user (or the user who posted the message with the given ID) for sending spam. This will also block them.</para></listitem></varlistentry>
    2021<varlistentry><term>follow &lt;screenname&gt;</term><listitem><para>Start following a person</para></listitem></varlistentry>
  • protocols/twitter/twitter.c

    r3da21ce rb8b931d  
    918918        gboolean allow_post =
    919919                g_strcasecmp(set_getstr(&ic->acc->set, "commands"), "strict") != 0;
     920        gboolean auto_populate_reply_metadata = FALSE;
    920921        bee_user_t *bu = NULL;
    921922
     
    996997                in_reply_to = id;
    997998                allow_post = TRUE;
     999        } else if (g_strcasecmp(cmd[0], "greply") == 0 && cmd[1] && cmd[2]) {
     1000                id = twitter_message_id_from_command_arg(ic, cmd[1], &bu);
     1001                if (!id || !bu) {
     1002                        twitter_log(ic, "User `%s' does not exist or didn't "
     1003                                    "post any statuses recently", cmd[1]);
     1004                        goto eof;
     1005                }
     1006                message = new = g_strdup_printf("%s", cmd[2]);
     1007                in_reply_to = id;
     1008                auto_populate_reply_metadata = TRUE;
     1009                allow_post = TRUE;
    9981010        } else if (g_strcasecmp(cmd[0], "rawreply") == 0 && cmd[1] && cmd[2]) {
    9991011                id = twitter_message_id_from_command_arg(ic, cmd[1], NULL);
     
    10471059                   this would delete the second-last Tweet. Prevent that. */
    10481060                td->last_status_id = 0;
    1049                 twitter_post_status(ic, message, in_reply_to);
     1061                twitter_post_status(ic, message, in_reply_to, auto_populate_reply_metadata);
    10501062        } else {
    10511063                twitter_log(ic, "Unknown command: %s", cmd[0]);
  • protocols/twitter/twitter_lib.c

    r3da21ce rb8b931d  
    16961696 * Function to POST a new status to twitter.
    16971697 */
    1698 void twitter_post_status(struct im_connection *ic, char *msg, guint64 in_reply_to)
    1699 {
    1700         char *args[4] = {
    1701                 "status", msg,
    1702                 "in_reply_to_status_id",
    1703                 g_strdup_printf("%" G_GUINT64_FORMAT, in_reply_to)
    1704         };
    1705 
    1706         if (set_getbool(&ic->acc->set, "in_korea") && !in_reply_to) {
    1707                 g_free(args[3]);
    1708                 args[2] = "place_id";
    1709                 args[3] = g_strdup("c999e6a453e9ef72");
     1698void twitter_post_status(struct im_connection *ic, char *msg, guint64 in_reply_to, gboolean auto_populate_reply_metadata)
     1699{
     1700        size_t args_len = 0;
     1701        char * in_reply_to_str = NULL;
     1702        char * place_id_str = NULL;
     1703        gboolean in_korea = (set_getbool(&ic->acc->set, "in_korea") && !in_reply_to);
     1704
     1705        args_len = 2; /* "status", msg */
     1706        if (in_reply_to) {
     1707                args_len += 2;
     1708        }
     1709        if (auto_populate_reply_metadata) {
     1710                args_len += 2;
     1711        }
     1712        if (in_korea) {
     1713                args_len += 2;
     1714        }
     1715
     1716        char **args = g_new0(char *, args_len);
     1717        args_len = 0;
     1718        args[args_len++] = "status";
     1719        args[args_len++] = msg;
     1720        if (in_reply_to) {
     1721                in_reply_to_str = g_strdup_printf("%" G_GUINT64_FORMAT, in_reply_to);
     1722                args[args_len++] = "in_reply_to_status_id";
     1723                args[args_len++] = in_reply_to_str;
     1724        }
     1725        if (auto_populate_reply_metadata) {
     1726                args[args_len++] = "auto_populate_reply_metadata";
     1727                args[args_len++] = "true";
     1728        }
     1729        if (in_korea) {
     1730                place_id_str = g_strdup("c999e6a453e9ef72");
     1731                args[args_len++] = "place_id";
     1732                args[args_len++] = place_id_str;
    17101733                in_reply_to = 1;
    17111734        }
    17121735
    17131736        twitter_http(ic, TWITTER_STATUS_UPDATE_URL, twitter_http_post, ic, 1,
    1714                      args, in_reply_to ? 4 : 2);
    1715         g_free(args[3]);
     1737                     args, args_len);
     1738        if (in_reply_to_str) {
     1739                g_free(in_reply_to_str);
     1740        }
     1741        if (place_id_str) {
     1742                g_free(place_id_str);
     1743        }
     1744        g_free(args);
    17161745}
    17171746
  • protocols/twitter/twitter_lib.h

    r3da21ce rb8b931d  
    9696void twitter_get_statuses_friends(struct im_connection *ic, gint64 next_cursor);
    9797
    98 void twitter_post_status(struct im_connection *ic, char *msg, guint64 in_reply_to);
     98void twitter_post_status(struct im_connection *ic, char *msg, guint64 in_reply_to, gboolean auto_populate_reply_metadata);
    9999void twitter_direct_messages_new(struct im_connection *ic, char *who, char *message);
    100100void twitter_friendships_create_destroy(struct im_connection *ic, char *who, int create);
Note: See TracChangeset for help on using the changeset viewer.