diff options
author | dequis <dx@dxzone.com.ar> | 2016-12-27 14:24:50 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2016-12-27 14:24:50 -0300 |
commit | 7801298f6a855cda0c62433d45ec717d2773ef73 (patch) | |
tree | 0c7cfab0f55843c0f216ff7cb6130804adae4e34 | |
parent | 9cdcef077ed523966f508a3721944a16425734cb (diff) |
Per-account handle_unknown
Credit for the idea goes to russian XMPP spammers. Thanks!
-rw-r--r-- | doc/user-guide/commands.xml | 10 | ||||
-rw-r--r-- | irc_im.c | 7 | ||||
-rw-r--r-- | protocols/account.c | 3 | ||||
-rw-r--r-- | protocols/bee_user.c | 10 |
4 files changed, 21 insertions, 9 deletions
diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 91e02ff2..1ddf9764 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -1007,19 +1007,23 @@ </description> </bitlbee-setting> - <bitlbee-setting name="handle_unknown" type="string" scope="global"> + <bitlbee-setting name="handle_unknown" type="string" scope="account,global"> <default>add_channel</default> - <possible-values>root, add, add_private, add_channel, ignore</possible-values> + <possible-values>add_private, add_channel, ignore</possible-values> <description> <para> - By default, messages from people who aren't in your contact list are shown in a control channel instead of as a private message. + 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) </para> <para> 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. </para> + <para> + 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. + </para> + <note> <para> Although these users will appear in your control channel, they aren't added to your real contact list. When you restart BitlBee, these auto-added users will be gone. If you want to keep someone in your list, you have to fixate the add using the <emphasis>add</emphasis> command. @@ -88,11 +88,12 @@ static gboolean bee_irc_user_new(bee_t *bee, bee_user_t *bu) str_reject_chars(iu->host, " ", '_'); if (bu->flags & BEE_USER_LOCAL) { - char *s = set_getstr(&bee->set, "handle_unknown"); + char *s = set_getstr(&bu->ic->acc->set, "handle_unknown") ? : + set_getstr(&bee->set, "handle_unknown"); - if (strcmp(s, "add_private") == 0) { + if (g_strcasecmp(s, "add_private") == 0) { iu->last_channel = NULL; - } else if (strcmp(s, "add_channel") == 0) { + } else if (g_strcasecmp(s, "add_channel") == 0) { iu->last_channel = irc->default_channel; } } diff --git a/protocols/account.c b/protocols/account.c index 1f12f56f..b5ff4e88 100644 --- a/protocols/account.c +++ b/protocols/account.c @@ -59,6 +59,9 @@ account_t *account_add(bee_t *bee, struct prpl *prpl, char *user, char *pass) s = set_add(&a->set, "auto_reconnect", "true", set_eval_bool, a); + s = set_add(&a->set, "handle_unknown", NULL, NULL, a); + s->flags |= SET_NULL_OK; + s = set_add(&a->set, "nick_format", NULL, NULL, a); s->flags |= SET_NULL_OK; diff --git a/protocols/bee_user.c b/protocols/bee_user.c index ced92ee9..79c99ec9 100644 --- a/protocols/bee_user.c +++ b/protocols/bee_user.c @@ -169,10 +169,13 @@ void imcb_buddy_status(struct im_connection *ic, const char *handle, int flags, bee_user_t *bu, *old; if (!(bu = bee_user_by_handle(bee, ic, handle))) { - if (g_strcasecmp(set_getstr(&ic->bee->set, "handle_unknown"), "add") == 0) { + char *h = set_getstr(&ic->acc->set, "handle_unknown") ? : + set_getstr(&ic->bee->set, "handle_unknown"); + + if (g_strncasecmp(h, "add", 3) == 0) { bu = bee_user_new(bee, ic, handle, BEE_USER_LOCAL); } else { - if (g_strcasecmp(set_getstr(&ic->bee->set, "handle_unknown"), "ignore") != 0) { + if (g_strcasecmp(h, "ignore") != 0) { imcb_log(ic, "imcb_buddy_status() for unknown handle %s:\n" "flags = %d, state = %s, message = %s", handle, flags, state ? state : "NULL", message ? message : "NULL"); @@ -254,7 +257,8 @@ void imcb_buddy_msg(struct im_connection *ic, const char *handle, const char *ms bu = bee_user_by_handle(bee, ic, handle); if (!bu && !(ic->flags & OPT_LOGGING_OUT)) { - char *h = set_getstr(&bee->set, "handle_unknown"); + char *h = set_getstr(&ic->acc->set, "handle_unknown") ? : + set_getstr(&ic->bee->set, "handle_unknown"); if (g_strcasecmp(h, "ignore") == 0) { return; |