Changeset 7801298


Ignore:
Timestamp:
2016-12-27T17:24:50Z (7 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
2e8523b
Parents:
9cdcef0
Message:

Per-account handle_unknown

Credit for the idea goes to russian XMPP spammers. Thanks!

Files:
4 edited

Legend:

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

    r9cdcef0 r7801298  
    10081008        </bitlbee-setting>
    10091009
    1010         <bitlbee-setting name="handle_unknown" type="string" scope="global">
     1010        <bitlbee-setting name="handle_unknown" type="string" scope="account,global">
    10111011                <default>add_channel</default>
    1012                 <possible-values>root, add, add_private, add_channel, ignore</possible-values>
    1013 
    1014                 <description>
    1015                         <para>
    1016                                 By default, messages from people who aren't in your contact list are shown in a control channel instead of as a private message.
     1012                <possible-values>add_private, add_channel, ignore</possible-values>
     1013
     1014                <description>
     1015                        <para>
     1016                                By default, messages from people who aren't in your contact list are shown in a control channel (add_channel) instead of as a private message (add_private)
    10171017                        </para>
    10181018
    10191019                        <para>
    10201020                                If you prefer to ignore messages from people you don't know, you can set this one to "ignore". "add_private" and "add_channel" are like add, but you can use them to make messages from unknown buddies appear in the channel instead of a query window.
     1021                        </para>
     1022
     1023                        <para>
     1024                                This can be set to individual accounts, which is useful to only ignore accounts that are targeted by spammers, without missing messages from legitimate unknown contacts in others. Note that incoming add requests are visible regardless of this setting.
    10211025                        </para>
    10221026
  • irc_im.c

    r9cdcef0 r7801298  
    8989
    9090        if (bu->flags & BEE_USER_LOCAL) {
    91                 char *s = set_getstr(&bee->set, "handle_unknown");
    92 
    93                 if (strcmp(s, "add_private") == 0) {
     91                char *s = set_getstr(&bu->ic->acc->set, "handle_unknown") ? :
     92                          set_getstr(&bee->set, "handle_unknown");
     93
     94                if (g_strcasecmp(s, "add_private") == 0) {
    9495                        iu->last_channel = NULL;
    95                 } else if (strcmp(s, "add_channel") == 0) {
     96                } else if (g_strcasecmp(s, "add_channel") == 0) {
    9697                        iu->last_channel = irc->default_channel;
    9798                }
  • protocols/account.c

    r9cdcef0 r7801298  
    5959
    6060        s = set_add(&a->set, "auto_reconnect", "true", set_eval_bool, a);
     61
     62        s = set_add(&a->set, "handle_unknown", NULL, NULL, a);
     63        s->flags |= SET_NULL_OK;
    6164
    6265        s = set_add(&a->set, "nick_format", NULL, NULL, a);
  • protocols/bee_user.c

    r9cdcef0 r7801298  
    170170
    171171        if (!(bu = bee_user_by_handle(bee, ic, handle))) {
    172                 if (g_strcasecmp(set_getstr(&ic->bee->set, "handle_unknown"), "add") == 0) {
     172                char *h = set_getstr(&ic->acc->set, "handle_unknown") ? :
     173                          set_getstr(&ic->bee->set, "handle_unknown");
     174
     175                if (g_strncasecmp(h, "add", 3) == 0) {
    173176                        bu = bee_user_new(bee, ic, handle, BEE_USER_LOCAL);
    174177                } else {
    175                         if (g_strcasecmp(set_getstr(&ic->bee->set, "handle_unknown"), "ignore") != 0) {
     178                        if (g_strcasecmp(h, "ignore") != 0) {
    176179                                imcb_log(ic, "imcb_buddy_status() for unknown handle %s:\n"
    177180                                         "flags = %d, state = %s, message = %s", handle, flags,
     
    255258
    256259        if (!bu && !(ic->flags & OPT_LOGGING_OUT)) {
    257                 char *h = set_getstr(&bee->set, "handle_unknown");
     260                char *h = set_getstr(&ic->acc->set, "handle_unknown") ? :
     261                          set_getstr(&ic->bee->set, "handle_unknown");
    258262
    259263                if (g_strcasecmp(h, "ignore") == 0) {
Note: See TracChangeset for help on using the changeset viewer.