From d3b84eaf6c5235b473b46d83234d10369861b039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 13 Aug 2022 22:15:29 +0200 Subject: irc: display CHGHOST command in private buffers --- src/plugins/irc/irc-protocol.c | 96 +++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 34 deletions(-) (limited to 'src/plugins') 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); - - 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); + 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); + } + break; } } -- cgit v1.2.3