Changeset 3592b95


Ignore:
Timestamp:
2012-11-25T20:21:24Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
f97b8e9
Parents:
9ed0081
Message:

To address #991, adding a strict commands mode, where one has to use "post"
to post tweets.

Files:
2 edited

Legend:

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

    r9ed0081 r3592b95  
    835835        <bitlbee-setting name="commands" type="boolean" scope="account">
    836836                <default>true</default>
     837                <possible-values>true, false, strict</possible-values>
    837838
    838839                <description>
     
    853854
    854855                        <para>
    855                                 Anything that doesn't look like a command will be treated as a tweet. Watch out for typos! :-)
     856                                Anything that doesn't look like a command will be treated as a tweet. Watch out for typos, or to avoid this behaviour, you can set this setting to <emphasis>strict</emphasis>, which causes the <emphasis>post</emphasis> command to become mandatory for posting a tweet.
    856857                        </para>
    857858                </description>
  • protocols/twitter/twitter.c

    r9ed0081 r3592b95  
    219219}
    220220
    221 
    222 static char *set_eval_mode(set_t * set, char *value)
    223 {
    224         if (g_strcasecmp(value, "one") == 0 ||
    225             g_strcasecmp(value, "many") == 0 || g_strcasecmp(value, "chat") == 0)
    226                 return value;
    227         else
    228                 return NULL;
    229 }
    230 
    231221int twitter_url_len_diff(gchar *msg, unsigned int target_len)
    232222{
     
    270260}
    271261
     262static char *set_eval_commands(set_t * set, char *value)
     263{
     264        if (g_strcasecmp(value, "strict") == 0 )
     265                return value;
     266        else
     267                return set_eval_bool(set, value);
     268}
     269
     270static char *set_eval_mode(set_t * set, char *value)
     271{
     272        if (g_strcasecmp(value, "one") == 0 ||
     273            g_strcasecmp(value, "many") == 0 || g_strcasecmp(value, "chat") == 0)
     274                return value;
     275        else
     276                return NULL;
     277}
     278
    272279static void twitter_init(account_t * acc)
    273280{
     
    289296        s->flags |= ACC_SET_OFFLINE_ONLY;
    290297
    291         s = set_add(&acc->set, "commands", "true", set_eval_bool, acc);
     298        s = set_add(&acc->set, "commands", "true", set_eval_commands, acc);
    292299
    293300        s = set_add(&acc->set, "fetch_interval", "60", set_eval_int, acc);
     
    569576        char *cmds, **cmd, *new = NULL;
    570577        guint64 in_reply_to = 0;
     578        gboolean strict_commands =
     579                g_strcasecmp(set_getstr(&ic->acc->set, "commands"), "strict") == 0;
    571580
    572581        cmds = g_strdup(message);
     
    576585                g_free(cmds);
    577586                return;
    578         } else if (!set_getbool(&ic->acc->set, "commands")) {
     587        } else if (!(strict_commands || set_getbool(&ic->acc->set, "commands"))) {
    579588                /* Not supporting commands. */
    580589        } else if (g_strcasecmp(cmd[0], "undo") == 0) {
     
    675684        } else if (g_strcasecmp(cmd[0], "post") == 0) {
    676685                message += 5;
    677         }
    678 
    679         {
     686                strict_commands = FALSE;
     687        }
     688
     689        if (strict_commands) {
     690                twitter_log(ic, "Unknown command: %s", cmd[0]);
     691        } else {
    680692                char *s;
    681693                bee_user_t *bu;
Note: See TracChangeset for help on using the changeset viewer.