diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-08-28 21:39:21 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-08-28 21:39:21 +0200 |
commit | 75cc0b0a77e84efc0d14182ae35f357247243260 (patch) | |
tree | 583fbd1b2e65a18b44108deb13cb5bb2859305dc /src/plugins/irc | |
parent | fb51fb605246d47ad68225d6dd2a149aa160c1d9 (diff) | |
download | weechat-75cc0b0a77e84efc0d14182ae35f357247243260.zip |
irc: add option irc.look.notice_welcome_redirect to automatically redirect channel welcome notices to the channel buffer
Diffstat (limited to 'src/plugins/irc')
-rw-r--r-- | src/plugins/irc/irc-config.c | 9 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 54 |
3 files changed, 61 insertions, 3 deletions
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 78bf50169..b74b49fe2 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -86,6 +86,7 @@ struct t_config_option *irc_config_look_nick_completion_smart; struct t_config_option *irc_config_look_nick_mode; struct t_config_option *irc_config_look_nick_mode_empty; struct t_config_option *irc_config_look_notice_as_pv; +struct t_config_option *irc_config_look_notice_welcome_redirect; struct t_config_option *irc_config_look_notify_tags_ison; struct t_config_option *irc_config_look_notify_tags_whois; struct t_config_option *irc_config_look_part_closes_buffer; @@ -2444,6 +2445,14 @@ irc_config_init () N_("display notices as private messages (if auto, use private buffer " "if found)"), "auto|never|always", 0, 0, "auto", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + irc_config_look_notice_welcome_redirect = weechat_config_new_option ( + irc_config_file, ptr_section, + "notice_welcome_redirect", "boolean", + N_("automatically redirect channel welcome notices to the channel " + "buffer; such notices have the nick as target but a channel name in " + "beginning of notice message, for example notices sent by freenode " + "server which look like: \"[#channel] Welcome to this channel...\""), + NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_notify_tags_ison = weechat_config_new_option ( irc_config_file, ptr_section, "notify_tags_ison", "string", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index a5762ef91..025c85829 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -134,6 +134,7 @@ extern struct t_config_option *irc_config_look_nick_completion_smart; extern struct t_config_option *irc_config_look_nick_mode; extern struct t_config_option *irc_config_look_nick_mode_empty; extern struct t_config_option *irc_config_look_notice_as_pv; +extern struct t_config_option *irc_config_look_notice_welcome_redirect; extern struct t_config_option *irc_config_look_notify_tags_ison; extern struct t_config_option *irc_config_look_notify_tags_whois; extern struct t_config_option *irc_config_look_part_closes_buffer; diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 49072db41..eedad00fd 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -1057,7 +1057,7 @@ IRC_PROTOCOL_CALLBACK(nick) IRC_PROTOCOL_CALLBACK(notice) { - char *pos_target, *pos_args; + char *pos_target, *pos_args, *pos, end_char, *channel; struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; int notify_private, is_channel, notice_op, notice_voice; @@ -1105,10 +1105,56 @@ IRC_PROTOCOL_CALLBACK(notice) } else { - if (pos_target && irc_channel_is_channel (server, pos_target)) + is_channel = 0; + channel = NULL; + if (pos_target) + { + is_channel = irc_channel_is_channel (server, pos_target); + if (is_channel) + { + channel = strdup (pos_target); + } + else if (weechat_config_boolean (irc_config_look_notice_welcome_redirect)) + { + end_char = ' '; + switch (pos_args[0]) + { + case '[': + end_char = ']'; + break; + case '(': + end_char = ')'; + break; + case '{': + end_char = '}'; + break; + case '<': + end_char = '>'; + break; + } + if (end_char != ' ') + { + pos = strchr (pos_args, end_char); + if (pos) + { + channel = weechat_strndup (pos_args + 1, pos - pos_args - 1); + if (channel && irc_channel_search (server, channel)) + { + is_channel = 1; + pos_args = pos + 1; + while (pos_args[0] == ' ') + { + pos_args++; + } + } + } + } + } + } + if (is_channel) { /* notice for channel */ - ptr_channel = irc_channel_search (server, pos_target); + ptr_channel = irc_channel_search (server, channel); /* * unmask a smart filtered join if it is in hashtable @@ -1284,6 +1330,8 @@ IRC_PROTOCOL_CALLBACK(notice) } } } + if (channel) + free (channel); } return WEECHAT_RC_OK; |