]> jfr.im git - irc/weechat/weechat.git/commitdiff
irc: don't open a new private buffer on `/msg` command when capability echo-message...
authorSébastien Helleu <redacted>
Thu, 14 Sep 2023 09:21:25 +0000 (11:21 +0200)
committerSébastien Helleu <redacted>
Thu, 14 Sep 2023 09:21:25 +0000 (11:21 +0200)
ChangeLog.adoc
src/plugins/irc/irc-protocol.c
tests/unit/plugins/irc/test-irc-protocol.cpp

index f6f7d9e2c46943564db49799479f64c275b74014..ac1377b576d65d84072285a477faac13308c2b22 100644 (file)
@@ -21,6 +21,7 @@ New features::
 
 Bug fixes::
 
+  * irc: don't open a new private buffer on `/msg` command when capability echo-message is enabled (issue #2016)
   * irc: fix title of private buffers wrongly set to own address when capability echo-message is enabled (issue #2016)
   * irc: fix autojoin of channels when private buffers are opened (issue #2012)
   * irc: fix string comparison when CASEMAPPING is set to "ascii"
index 60e90595135070f34c7e59f09b59f198388a0eb9..b537c155353e9633695c6be55e1d31301a7509df 100644 (file)
@@ -3231,7 +3231,7 @@ IRC_PROTOCOL_CALLBACK(privmsg)
             if (strcmp (ptr_channel->name, remote_nick) != 0)
                 irc_channel_pv_rename (server, ptr_channel, remote_nick);
         }
-        else
+        else if (!nick_is_me)
         {
             ptr_channel = irc_channel_new (server,
                                            IRC_CHANNEL_TYPE_PRIVATE,
@@ -3247,7 +3247,8 @@ IRC_PROTOCOL_CALLBACK(privmsg)
             }
         }
 
-        if (weechat_config_boolean (irc_config_look_typing_status_nicks))
+        if (ptr_channel
+            && weechat_config_boolean (irc_config_look_typing_status_nicks))
         {
             irc_typing_channel_set_nick (ptr_channel, nick,
                                          IRC_CHANNEL_TYPING_STATE_OFF);
@@ -3261,7 +3262,8 @@ IRC_PROTOCOL_CALLBACK(privmsg)
         }
         else
         {
-            irc_channel_set_topic (ptr_channel, address);
+            if (ptr_channel)
+                irc_channel_set_topic (ptr_channel, address);
             if (weechat_config_boolean (irc_config_look_color_pv_nick_like_channel))
             {
                 color = irc_nick_find_color_name (nick);
@@ -3295,20 +3297,35 @@ IRC_PROTOCOL_CALLBACK(privmsg)
             free (str_color);
         msg_args2 = (nick_is_me) ?
             irc_message_hide_password (server, remote_nick, msg_args) : NULL;
-        weechat_printf_date_tags (
-            ptr_channel->buffer,
-            date,
-            irc_protocol_tags (server, command, tags, str_tags, nick, address),
-            "%s%s",
-            irc_nick_as_prefix (
-                server, NULL, nick,
-                (nick_is_me) ?
-                IRC_COLOR_CHAT_NICK_SELF : irc_nick_color_for_pv (ptr_channel, nick)),
-            (msg_args2) ? msg_args2 : msg_args);
+        if (nick_is_me && !ptr_channel)
+        {
+            irc_input_user_message_display (
+                server,
+                date,
+                remote_nick,
+                address,
+                "privmsg",
+                NULL,  /* ctcp_type */
+                (msg_args2) ? msg_args2 : msg_args,
+                1);  /* decode_colors */
+        }
+        else
+        {
+            weechat_printf_date_tags (
+                ptr_channel->buffer,
+                date,
+                irc_protocol_tags (server, command, tags, str_tags, nick, address),
+                "%s%s",
+                irc_nick_as_prefix (
+                    server, NULL, nick,
+                    (nick_is_me) ?
+                    IRC_COLOR_CHAT_NICK_SELF : irc_nick_color_for_pv (ptr_channel, nick)),
+                (msg_args2) ? msg_args2 : msg_args);
+        }
         if (msg_args2)
             free (msg_args2);
 
-        if (ptr_channel->has_quit_server)
+        if (ptr_channel && ptr_channel->has_quit_server)
             ptr_channel->has_quit_server = 0;
 
         (void) weechat_hook_signal_send ("irc_pv",
index ae969324afc12b8881ae2c0b79c24510307f3bf9..c8cf5440c81fdd271de66a4d14714956f01e85a3 100644 (file)
@@ -2780,19 +2780,19 @@ TEST(IrcProtocolWithServer, privmsg)
          * message from self nick in private
          * (case of bouncer or if echo-message capability is enabled)
          */
-        RECV(":alice!user@host PRIVMSG alice :this is the message ");
-        CHECK_PV("alice", "alice", "this is the message ",
-                 "irc_privmsg,self_msg,notify_none,no_highlight,"
-                 "prefix_nick_white,nick_alice,host_user@host,log1");
+        RECV(":alice!user@host PRIVMSG bob2 :this is the message ");
+        CHECK_SRV("--", "Msg(alice) -> bob2: this is the message ",
+                  "irc_privmsg,self_msg,notify_none,no_highlight,"
+                  "nick_alice,host_user@host,log1");
 
         /*
          * message from self nick in private, with password hidden (nickserv)
          * (case of bouncer or if echo-message capability is enabled)
          */
         RECV(":alice!user@host PRIVMSG nickserv :identify secret");
-        CHECK_PV("nickserv", "alice", "identify ******",
-                 "irc_privmsg,self_msg,notify_none,no_highlight,"
-                 "prefix_nick_white,nick_alice,host_user@host,log1");
+        CHECK_SRV("--", "Msg(alice) -> nickserv: identify ******",
+                  "irc_privmsg,self_msg,notify_none,no_highlight,"
+                  "nick_alice,host_user@host,log1");
 
         /* broken CTCP to channel */
         RECV(":bob!user@host PRIVMSG #test :\01");
@@ -2974,7 +2974,7 @@ TEST(IrcProtocolWithServer, privmsg)
         }
         else
         {
-            CHECK_PV("alice", "--", "CTCP query to alice: CLIENTINFO",
+            CHECK_SRV("--", "CTCP query to alice: CLIENTINFO",
                      "irc_privmsg,irc_ctcp,self_msg,notify_none,no_highlight,"
                      "nick_alice,host_user@host,log1");
             /*