]> jfr.im git - irc/weechat/weechat.git/commitdiff
irc: display CHGHOST command in private buffers
authorSébastien Helleu <redacted>
Sat, 13 Aug 2022 20:15:29 +0000 (22:15 +0200)
committerSébastien Helleu <redacted>
Sat, 13 Aug 2022 20:16:46 +0000 (22:16 +0200)
ChangeLog.adoc
src/plugins/irc/irc-protocol.c
tests/unit/plugins/irc/test-irc-protocol.cpp

index af7a3e00d74bac862151fd878a1dc27b5456b05e..deccd75dc91b5d628cdda49716756707c057c3b3 100644 (file)
@@ -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
index a082e527508b6bf16a8929a1b5abc38f0c298704..4af1b0e31368c11566412d8ef0b01e48bef830c4 100644 (file)
@@ -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;
         }
     }
 
index c3d3872aad792c648f38b00daae17bf219f93329..7240cd461247b4aef180870681b902392db4f684 100644 (file)
@@ -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");
 }
 
 /*