diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-06 16:42:15 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-06 16:42:15 +0200 |
commit | 74729ce677d81d17753be64bb409fff41bcb5343 (patch) | |
tree | 4b5c311b60b4ae9c8a8069bf4108506e121e1193 | |
parent | d81170b010fdb770566075ec64e19a66abd42469 (diff) | |
download | weechat-74729ce677d81d17753be64bb409fff41bcb5343.zip |
irc: display CTCP reply to a nick in server buffer instead of channel
When a CTCP request is received on a channel, WeeChat replies to the nick and
it is now displayed in the server buffer instead of the channel, as the target
is a nick and not a channel.
-rw-r--r-- | src/plugins/irc/irc-ctcp.c | 17 | ||||
-rw-r--r-- | tests/unit/plugins/irc/test-irc-protocol.cpp | 22 |
2 files changed, 16 insertions, 23 deletions
diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c index c5368a44c..8b400041f 100644 --- a/src/plugins/irc/irc-ctcp.c +++ b/src/plugins/irc/irc-ctcp.c @@ -324,7 +324,6 @@ irc_ctcp_display_reply_from_nick (struct t_irc_protocol_ctxt *ctxt, void irc_ctcp_reply_to_nick (struct t_irc_protocol_ctxt *ctxt, - struct t_irc_channel *channel, const char *ctcp, const char *arguments) { @@ -386,11 +385,8 @@ irc_ctcp_reply_to_nick (struct t_irc_protocol_ctxt *ctxt, if (!msg_color) break; weechat_printf_date_tags ( - irc_msgbuffer_get_target_buffer ( - ctxt->server, ctxt->nick, - NULL, - "ctcp", - (channel) ? channel->buffer : NULL), + irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->nick, + NULL, "ctcp", NULL), 0, irc_protocol_tags (ctxt, "irc_ctcp,irc_ctcp_reply,self_msg," @@ -1498,15 +1494,13 @@ irc_ctcp_recv (struct t_irc_protocol_ctxt *ctxt, reply_eval = irc_ctcp_eval_reply (ctxt->server, reply); if (reply_eval) { - irc_ctcp_reply_to_nick (ctxt, channel, ptr_args + 1, - reply_eval); + irc_ctcp_reply_to_nick (ctxt, ptr_args + 1, reply_eval); free (reply_eval); } } else { - irc_ctcp_reply_to_nick (ctxt, channel, ptr_args + 1, - pos_args); + irc_ctcp_reply_to_nick (ctxt, ptr_args + 1, pos_args); } } } @@ -1530,8 +1524,7 @@ irc_ctcp_recv (struct t_irc_protocol_ctxt *ctxt, reply_eval = irc_ctcp_eval_reply (ctxt->server, reply); if (reply_eval) { - irc_ctcp_reply_to_nick (ctxt, channel, ptr_args + 1, - reply_eval); + irc_ctcp_reply_to_nick (ctxt, ptr_args + 1, reply_eval); free (reply_eval); } } diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index 690a86739..ca2e25c88 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -3041,9 +3041,9 @@ TEST(IrcProtocolWithServer, privmsg) "irc_privmsg,irc_ctcp,nick_bob,host_user@host,log1"); snprintf (message, sizeof (message), "CTCP reply to bob: VERSION %s", info); - CHECK_CHAN("--", message, - "irc_privmsg,irc_ctcp,irc_ctcp_reply,self_msg,notify_none," - "no_highlight,nick_alice,log1"); + CHECK_SRV("--", message, + "irc_privmsg,irc_ctcp,irc_ctcp_reply,self_msg,notify_none," + "no_highlight,nick_alice,log1"); snprintf (message, sizeof (message), "NOTICE bob :\01VERSION %s\01", info); CHECK_SENT(message); @@ -3131,10 +3131,10 @@ TEST(IrcProtocolWithServer, privmsg) CHECK_CHAN("--", "CTCP requested by bob: PING 1703496549 905284", "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," "irc_ctcp,nick_bob,host_user@host,log1"); - CHECK_CHAN("--", "CTCP reply to bob: PING 1703496549 905284", - "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," - "irc_ctcp,irc_ctcp_reply,self_msg,notify_none," - "no_highlight,nick_alice,log1"); + CHECK_SRV("--", "CTCP reply to bob: PING 1703496549 905284", + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_ctcp,irc_ctcp_reply,self_msg,notify_none," + "no_highlight,nick_alice,log1"); RECV("@time=2023-12-25T10:29:09.456789Z " ":bob!user@host PRIVMSG #test :\01UNKNOWN\01"); CHECK_SENT(NULL); @@ -3161,10 +3161,10 @@ TEST(IrcProtocolWithServer, privmsg) CHECK_CHAN("--", "CTCP requested by bob: PING 1703496549 905284", "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," "irc_ctcp,nick_bob,host_user@host,log1"); - CHECK_CHAN("--", "CTCP reply to bob: PING 1703496549 905284", - "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," - "irc_ctcp,irc_ctcp_reply,self_msg,notify_none," - "no_highlight,nick_alice,log1"); + CHECK_SRV("--", "CTCP reply to bob: PING 1703496549 905284", + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_ctcp,irc_ctcp_reply,self_msg,notify_none," + "no_highlight,nick_alice,log1"); RECV("@time=2023-12-25T10:29:09.456789Z " ":bob!user@host PRIVMSG @#test :\01UNKNOWN\01"); CHECK_SENT(NULL); |