1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 13:26:38 +02:00

irc: add smart filtering for chghost messages

This commit is contained in:
Simmo Saan
2016-01-07 13:01:00 +02:00
parent bf9932bc1d
commit 227537cbdb
4 changed files with 48 additions and 20 deletions
+5 -3
View File
@@ -1084,8 +1084,8 @@ void
irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel,
const char *nick)
{
int i, unmask_delay, length_tags, nick_found, join, nick_changed;
int smart_filtered, remove_smart_filter;
int i, unmask_delay, length_tags, nick_found, join, chghost;
int nick_changed, smart_filtered, remove_smart_filter;
time_t *ptr_time, date_min;
struct t_hdata *hdata_line, *hdata_line_data;
struct t_gui_line *own_lines;
@@ -1174,6 +1174,8 @@ irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel,
}
else if (strcmp (tags[i], "irc_join") == 0)
join = 1;
else if (strcmp (tags[i], "irc_chghost") == 0)
chghost = 1;
else if (strcmp (tags[i], "irc_nick") == 0)
nick_changed = 1;
else if (strncmp (tags[i], "irc_nick1_", 10) == 0)
@@ -1197,7 +1199,7 @@ irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel,
break;
remove_smart_filter = 1;
}
else if (nick_found && join && smart_filtered)
else if (nick_found && (join || chghost) && smart_filtered)
{
remove_smart_filter = 1;
}
+8
View File
@@ -98,6 +98,7 @@ struct t_config_option *irc_config_look_pv_tags;
struct t_config_option *irc_config_look_raw_messages;
struct t_config_option *irc_config_look_server_buffer;
struct t_config_option *irc_config_look_smart_filter;
struct t_config_option *irc_config_look_smart_filter_chghost;
struct t_config_option *irc_config_look_smart_filter_delay;
struct t_config_option *irc_config_look_smart_filter_join;
struct t_config_option *irc_config_look_smart_filter_join_unmask;
@@ -2892,6 +2893,13 @@ irc_config_init ()
"\"irc_smart_filter\")"),
NULL, 0, 0, "on", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_smart_filter_chghost = weechat_config_new_option (
irc_config_file, ptr_section,
"smart_filter_chghost", "boolean",
/* TRANSLATORS: please do not translate "chghost" */
N_("enable smart filter for \"chghost\" messages"),
NULL, 0, 0, "on", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_smart_filter_delay = weechat_config_new_option (
irc_config_file, ptr_section,
"smart_filter_delay", "integer",
+1
View File
@@ -137,6 +137,7 @@ extern struct t_config_option *irc_config_look_pv_tags;
extern struct t_config_option *irc_config_look_raw_messages;
extern struct t_config_option *irc_config_look_server_buffer;
extern struct t_config_option *irc_config_look_smart_filter;
extern struct t_config_option *irc_config_look_smart_filter_chghost;
extern struct t_config_option *irc_config_look_smart_filter_delay;
extern struct t_config_option *irc_config_look_smart_filter_join;
extern struct t_config_option *irc_config_look_smart_filter_join_unmask;
+34 -17
View File
@@ -650,12 +650,16 @@ IRC_PROTOCOL_CALLBACK(cap)
IRC_PROTOCOL_CALLBACK(chghost)
{
int length;
int length, local_chghost, smart_filter;
char *str_host;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
struct t_irc_channel_speaking *ptr_nick_speaking;
IRC_PROTOCOL_MIN_ARGS(4);
IRC_PROTOCOL_CHECK_HOST;
local_chghost = (irc_server_strcasecmp (server, nick, server->nick) == 0);
length = strlen (argv[2]) + 1 + strlen (argv[3]) + 1;
str_host = malloc (length);
@@ -668,22 +672,35 @@ IRC_PROTOCOL_CALLBACK(chghost)
ptr_nick = irc_nick_search (server, ptr_channel, nick);
if (ptr_nick)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
irc_protocol_tags (command, NULL, nick, address),
_("%s%s%s%s (%s%s%s)%s has changed host to %s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, ptr_nick, nick),
nick,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
address,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_MESSAGE_CHGHOST,
IRC_COLOR_CHAT_HOST,
str_host);
if (!ignored)
{
ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter))
&& (weechat_config_boolean (irc_config_look_smart_filter_chghost))) ?
irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL;
smart_filter = (!local_chghost
&& weechat_config_boolean (irc_config_look_smart_filter)
&& weechat_config_boolean (irc_config_look_smart_filter_chghost)
&& !ptr_nick_speaking);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
irc_protocol_tags (command,
smart_filter ? "irc_smart_filter" : NULL,
nick, address),
_("%s%s%s%s (%s%s%s)%s has changed host to %s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, ptr_nick, nick),
nick,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
address,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_MESSAGE_CHGHOST,
IRC_COLOR_CHAT_HOST,
str_host);
}
if (ptr_nick->host)
free (ptr_nick->host);