summaryrefslogtreecommitdiff
path: root/src/plugins/irc
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2018-05-21 08:05:04 +0200
committerSébastien Helleu <flashcode@flashtux.org>2018-05-21 08:05:04 +0200
commitc0cb3a6178ad4d93248c6f6fca09d1b15d1c53c2 (patch)
treefec8ed1b430175d9c37e8af282e73e8bb8b04d30 /src/plugins/irc
parent7b15ffdb71958e48784c735ce277431ebd4593ca (diff)
parent8420abe8bbbbba71b80d777f5faac81b4efc1816 (diff)
downloadweechat-c0cb3a6178ad4d93248c6f6fca09d1b15d1c53c2.zip
Merge remote-tracking branch 'origin/pr/640'
Diffstat (limited to 'src/plugins/irc')
-rw-r--r--src/plugins/irc/irc-channel.c8
-rw-r--r--src/plugins/irc/irc-color.h1
-rw-r--r--src/plugins/irc/irc-command.c2
-rw-r--r--src/plugins/irc/irc-command.h2
-rw-r--r--src/plugins/irc/irc-config.c15
-rw-r--r--src/plugins/irc/irc-config.h2
-rw-r--r--src/plugins/irc/irc-protocol.c78
7 files changed, 103 insertions, 5 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index ab24038a0..89c7cd37d 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -1094,8 +1094,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;
@@ -1184,6 +1184,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)
@@ -1207,7 +1209,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;
}
diff --git a/src/plugins/irc/irc-color.h b/src/plugins/irc/irc-color.h
index 82004cff5..4375c3a5a 100644
--- a/src/plugins/irc/irc-color.h
+++ b/src/plugins/irc/irc-color.h
@@ -84,6 +84,7 @@
#define IRC_COLOR_STATUS_NAME weechat_color("status_name")
#define IRC_COLOR_STATUS_NAME_SSL weechat_color("status_name_ssl")
#define IRC_COLOR_MESSAGE_JOIN weechat_color(weechat_config_string(irc_config_color_message_join))
+#define IRC_COLOR_MESSAGE_CHGHOST weechat_color(weechat_config_string(irc_config_color_message_chghost))
#define IRC_COLOR_MESSAGE_QUIT weechat_color(weechat_config_string(irc_config_color_message_quit))
#define IRC_COLOR_REASON_QUIT weechat_color(weechat_config_string(irc_config_color_reason_quit))
#define IRC_COLOR_TOPIC_CURRENT weechat_color(weechat_config_string(irc_config_color_topic_current))
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 3ee172c06..9324fa701 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -6356,7 +6356,7 @@ irc_command_init ()
"Without argument, \"ls\" and \"list\" are sent.\n"
"\n"
"Capabilities supported by WeeChat are: "
- "account-notify, away-notify, cap-notify, extended-join, "
+ "account-notify, away-notify, cap-notify, chghost, extended-join, "
"invite-notify, multi-prefix, server-time, userhost-in-names.\n"
"\n"
"The capabilities to automatically enable on servers can be set "
diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h
index b6ec7b64f..8fdaad4b8 100644
--- a/src/plugins/irc/irc-command.h
+++ b/src/plugins/irc/irc-command.h
@@ -51,7 +51,7 @@ struct t_irc_channel;
/* list of supported capabilities (for completion in command /cap) */
#define IRC_COMMAND_CAP_SUPPORTED_COMPLETION \
- "account-notify|away-notify|cap-notify|extended-join|" \
+ "account-notify|away-notify|cap-notify|chghost|extended-join|" \
"invite-notify|multi-prefix|server-time|userhost-in-names|%*"
/* list of supported CTCPs (for completion in command /ctcp) */
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 04bccb25c..9a7d9dc10 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -97,6 +97,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;
@@ -114,6 +115,7 @@ struct t_config_option *irc_config_color_item_lag_counting;
struct t_config_option *irc_config_color_item_lag_finished;
struct t_config_option *irc_config_color_item_nick_modes;
struct t_config_option *irc_config_color_message_join;
+struct t_config_option *irc_config_color_message_chghost;
struct t_config_option *irc_config_color_message_quit;
struct t_config_option *irc_config_color_mirc_remap;
struct t_config_option *irc_config_color_nick_prefixes;
@@ -2885,6 +2887,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",
@@ -3013,6 +3022,12 @@ irc_config_init ()
N_("color for text in join messages"),
NULL, -1, 0, "green", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_color_message_chghost = weechat_config_new_option (
+ irc_config_file, ptr_section,
+ "message_chghost", "color",
+ N_("color for text in chghost messages"),
+ NULL, -1, 0, "brown", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_color_message_quit = weechat_config_new_option (
irc_config_file, ptr_section,
"message_quit", "color",
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index e27313614..9a418eacd 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -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;
@@ -152,6 +153,7 @@ extern struct t_config_option *irc_config_color_item_lag_counting;
extern struct t_config_option *irc_config_color_item_lag_finished;
extern struct t_config_option *irc_config_color_item_nick_modes;
extern struct t_config_option *irc_config_color_message_join;
+extern struct t_config_option *irc_config_color_message_chghost;
extern struct t_config_option *irc_config_color_message_quit;
extern struct t_config_option *irc_config_color_mirc_remap;
extern struct t_config_option *irc_config_color_nick_prefixes;
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 06419729d..f6a8a4564 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -760,6 +760,83 @@ IRC_PROTOCOL_CALLBACK(cap)
}
/*
+ * Callback for the IRC message "CHGHOST": user/host change of a nick (with
+ * capability "chghost"):
+ * http://ircv3.net/specs/extensions/chghost-3.2.html
+ *
+ * Message looks like:
+ * :nick!user@host CHGHOST user new.host.goes.here
+ * :nick!user@host CHGHOST newuser host
+ * :nick!user@host CHGHOST newuser new.host.goes.here
+ */
+
+IRC_PROTOCOL_CALLBACK(chghost)
+{
+ 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);
+ if (str_host)
+ snprintf (str_host, length, "%s@%s", argv[2], argv[3]);
+
+ for (ptr_channel = server->channels; ptr_channel;
+ ptr_channel = ptr_channel->next_channel)
+ {
+ ptr_nick = irc_nick_search (server, ptr_channel, nick);
+ if (ptr_nick)
+ {
+ 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);
+ ptr_nick->host = strdup (str_host);
+ }
+ }
+
+ if (str_host)
+ free (str_host);
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* Callback for the IRC message "ERROR".
*
* Message looks like:
@@ -6051,6 +6128,7 @@ irc_protocol_recv_command (struct t_irc_server *server,
{ "authenticate", /* authenticate */ 1, 0, &irc_protocol_cb_authenticate },
{ "away", /* away (cap away-notify) */ 1, 0, &irc_protocol_cb_away },
{ "cap", /* client capability */ 1, 0, &irc_protocol_cb_cap },
+ { "chghost", /* user/host change (cap chghost) */ 1, 0, &irc_protocol_cb_chghost },
{ "error", /* error received from IRC server */ 1, 0, &irc_protocol_cb_error },
{ "invite", /* invite a nick on a channel */ 1, 0, &irc_protocol_cb_invite },
{ "join", /* join a channel */ 1, 0, &irc_protocol_cb_join },