1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-07 02:03:13 +02:00

irc: add option irc.look.notice_welcome_redirect to automatically redirect channel welcome notices to the channel buffer

This commit is contained in:
Sebastien Helleu
2013-08-28 21:39:21 +02:00
parent fb51fb6052
commit 75cc0b0a77
21 changed files with 190 additions and 17 deletions
+9
View File
@@ -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",
+1
View File
@@ -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;
+51 -3
View File
@@ -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;