diff --git a/ChangeLog.adoc b/ChangeLog.adoc index af7a3e00d..deccd75dc 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -33,6 +33,7 @@ Bug fixes:: * irc: fix display of TOPIC and QUIT messages with an empty trailing parameter (issue #1797) * irc: fix parsing of messages with trailing spaces and no trailing parameter (issue #1803) * irc: add missing tag "irc_numeric" in all numeric IRC commands (issue #1804) + * irc: display CHGHOST command in private buffers * guile: fix function hdata_get_string * javascript: fix return of long value in functions infolist_time, hdata_long and hdata_time * php: fix function hdata_compare diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index a082e5275..4af1b0e31 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -1226,41 +1226,69 @@ IRC_PROTOCOL_CALLBACK(chghost) 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) + switch (ptr_channel->type) { - 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); + case IRC_CHANNEL_TYPE_PRIVATE: + if (!ignored + && (irc_server_strcasecmp (server, + ptr_channel->name, nick) == 0)) + { + weechat_printf_date_tags ( + irc_msgbuffer_get_target_buffer ( + server, NULL, command, NULL, ptr_channel->buffer), + date, + irc_protocol_tags (command, tags, 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) ? address : "", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_MESSAGE_CHGHOST, + IRC_COLOR_CHAT_HOST, + str_host); + } + break; + case IRC_CHANNEL_TYPE_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, - tags, - 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) ? address : "", - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_MESSAGE_CHGHOST, - IRC_COLOR_CHAT_HOST, - str_host); - } - irc_nick_set_host (ptr_nick, str_host); + weechat_printf_date_tags ( + irc_msgbuffer_get_target_buffer ( + server, NULL, command, NULL, ptr_channel->buffer), + date, + irc_protocol_tags ( + command, + tags, + 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) ? address : "", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_MESSAGE_CHGHOST, + IRC_COLOR_CHAT_HOST, + str_host); + } + irc_nick_set_host (ptr_nick, str_host); + } + break; } } diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index c3d3872aa..7240cd461 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -879,6 +879,8 @@ TEST(IrcProtocolWithServer, chghost) SRV_INIT_JOIN2; + RECV(":bob!user@host PRIVMSG alice :hi Alice!"); + ptr_nick = ptr_server->channels->nicks; ptr_nick2 = ptr_server->channels->last_nick; @@ -913,6 +915,7 @@ TEST(IrcProtocolWithServer, chghost) 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"); 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"); } /*