summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-06-04 09:45:47 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-06-04 09:45:47 +0200
commite04d8894a098cdd0f6ea015fdd0d5c62b2581ad3 (patch)
tree240bc9070c15caec427e53b4eda5902240750656
parent7f4c3a660a81959347d15d90341d11ddd9927ab9 (diff)
downloadweechat-e04d8894a098cdd0f6ea015fdd0d5c62b2581ad3.zip
irc: add tag "new_host_xxx" in message displayed for command CHGHOST (closes #1808)
-rw-r--r--ChangeLog.adoc1
-rw-r--r--src/plugins/irc/irc-protocol.c22
-rw-r--r--tests/unit/plugins/irc/test-irc-protocol.cpp12
3 files changed, 20 insertions, 15 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 2ed69051c..e52169737 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -63,6 +63,7 @@ New features::
* irc: add `${username}` in server options "nicks" and "username", change their default values to use it
* irc: add infos "irc_server_cap" and "irc_server_cap_value"
* irc: add option irc.look.display_host_notice
+ * irc: add tag "new_host_xxx" in message displayed for command CHGHOST (issue #1808)
* logger: add option logger.file.log_conditions (issue #1942)
* logger: add info "logger_log_file"
* relay: rename "ssl" options and protocol to "tls"
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index ac8487bd1..ee764cb1c 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -1367,7 +1367,7 @@ IRC_PROTOCOL_CALLBACK(cap)
IRC_PROTOCOL_CALLBACK(chghost)
{
int length, local_chghost, smart_filter;
- char *str_host;
+ char *str_host, str_tags[512];
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
struct t_irc_channel_speaking *ptr_nick_speaking;
@@ -1402,12 +1402,14 @@ IRC_PROTOCOL_CALLBACK(chghost)
&& (irc_server_strcasecmp (server,
ptr_channel->name, nick) == 0))
{
+ snprintf (str_tags, sizeof (str_tags),
+ "new_host_%s", str_host);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
- irc_protocol_tags (server, command, tags, NULL, nick,
- address),
+ irc_protocol_tags (server, command, tags, str_tags,
+ 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, NULL, nick),
@@ -1434,17 +1436,17 @@ IRC_PROTOCOL_CALLBACK(chghost)
&& weechat_config_boolean (irc_config_look_smart_filter)
&& weechat_config_boolean (irc_config_look_smart_filter_chghost)
&& !ptr_nick_speaking);
-
+ snprintf (str_tags, sizeof (str_tags),
+ "new_host_%s%s%s",
+ str_host,
+ (smart_filter) ? "," : "",
+ (smart_filter) ? "irc_smart_filter" : "");
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
- irc_protocol_tags (
- server,
- command,
- tags,
- (smart_filter) ? "irc_smart_filter" : NULL,
- nick, address),
+ irc_protocol_tags (server, command, tags, str_tags,
+ 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),
diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp
index 44ac3fc0c..aed04e590 100644
--- a/tests/unit/plugins/irc/test-irc-protocol.cpp
+++ b/tests/unit/plugins/irc/test-irc-protocol.cpp
@@ -1822,29 +1822,31 @@ TEST(IrcProtocolWithServer, chghost)
/* self nick */
RECV(":alice!user@host CHGHOST user2 host2");
CHECK_CHAN("--", "alice (user@host) has changed host to user2@host2",
- "irc_chghost,nick_alice,host_user@host,log3");
+ "irc_chghost,new_host_user2@host2,nick_alice,host_user@host,log3");
STRCMP_EQUAL("user2@host2", ptr_nick->host);
RECV(":alice!user@host CHGHOST user2 host2");
CHECK_CHAN("--", "alice (user@host) has changed host to user2@host2",
- "irc_chghost,nick_alice,host_user@host,log3");
+ "irc_chghost,new_host_user2@host2,nick_alice,host_user@host,log3");
STRCMP_EQUAL("user2@host2", ptr_nick->host);
RECV(":alice!user2@host2 CHGHOST user3 :host3");
CHECK_CHAN("--", "alice (user2@host2) has changed host to user3@host3",
- "irc_chghost,nick_alice,host_user2@host2,log3");
+ "irc_chghost,new_host_user3@host3,nick_alice,host_user2@host2,log3");
STRCMP_EQUAL("user3@host3", ptr_nick->host);
/* another nick */
RECV(":bob!user@host CHGHOST user_bob_2 host_bob_2");
CHECK_CHAN("--",
"bob (user@host) has changed host to user_bob_2@host_bob_2",
- "irc_chghost,irc_smart_filter,nick_bob,host_user@host,log3");
+ "irc_chghost,new_host_user_bob_2@host_bob_2,irc_smart_filter,"
+ "nick_bob,host_user@host,log3");
STRCMP_EQUAL("user_bob_2@host_bob_2", ptr_nick2->host);
CHECK_PV("bob",
"--",
"bob (user@host) has changed host to user_bob_2@host_bob_2",
- "irc_chghost,nick_bob,host_user@host,log3");
+ "irc_chghost,new_host_user_bob_2@host_bob_2,nick_bob,"
+ "host_user@host,log3");
}
/*