diff options
-rw-r--r-- | src/plugins/irc/irc-ctcp.c | 15 | ||||
-rw-r--r-- | tests/unit/plugins/irc/test-irc-protocol.cpp | 18 |
2 files changed, 25 insertions, 8 deletions
diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c index 0a0d32900..a84a7dae3 100644 --- a/src/plugins/irc/irc-ctcp.c +++ b/src/plugins/irc/irc-ctcp.c @@ -1300,16 +1300,20 @@ irc_ctcp_display_send (struct t_irc_server *server, const char *target, const char *type, const char *args) { struct t_irc_nick *ptr_nick; + int is_channel; if (weechat_strcasecmp (type, "action") == 0) { - if (channel - && irc_server_prefix_char_statusmsg (server, target[0])) + if (!channel || irc_server_prefix_char_statusmsg (server, target[0])) { - /* STATUSMSG action */ + /* no buffer or STATUSMSG action */ + is_channel = ((irc_server_prefix_char_statusmsg (server, target[0]) + && irc_channel_is_channel (server, target + 1)) + || irc_channel_is_channel (server, target)); ptr_nick = irc_nick_search (server, channel, server->nick); weechat_printf_date_tags ( - channel->buffer, + (channel) ? channel->buffer : irc_msgbuffer_get_target_buffer ( + server, target, NULL, "ctcp", NULL), 0, irc_protocol_tags ( server, @@ -1322,7 +1326,8 @@ irc_ctcp_display_send (struct t_irc_server *server, weechat_prefix ("network"), /* TRANSLATORS: "Action" is an IRC CTCP "ACTION" sent with /me */ _("Action"), - IRC_COLOR_CHAT_CHANNEL, + (is_channel) ? + IRC_COLOR_CHAT_CHANNEL : irc_nick_color_for_msg (server, 0, NULL, target), target, IRC_COLOR_RESET, irc_nick_mode_for_display (server, ptr_nick, 0), diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index 1cb2d5bbf..db02c85c7 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -711,12 +711,19 @@ TEST(IrcProtocolWithServer, SendMessagesWithoutEchoMessage) "nick_alice,log1"); /* action in private (with /ctcp) */ - server_input_data (buffer_server, "/ctcp bob ACTION action pv 2"); + server_input_data (buffer_server, "/ctcp bob action action pv 2"); CHECK_SENT("PRIVMSG bob :\01ACTION action pv 2\01"); CHECK_PV("bob", " *", "alice action pv 2", "irc_privmsg,irc_action,self_msg,notify_none,no_highlight," "nick_alice,log1"); + /* action in private (with /ctcp), without private buffer */ + server_input_data (buffer_server, "/ctcp bob2 action action pv 3"); + CHECK_SENT("PRIVMSG bob2 :\01ACTION action pv 3\01"); + CHECK_SRV("--", "Action -> bob2: alice action pv 3", + "irc_privmsg,irc_action,self_msg,notify_none,no_highlight," + "nick_alice,log1"); + /* CTCP version to channel */ server_input_data (buffer_server, "/ctcp #test version"); CHECK_SENT("PRIVMSG #test :\01VERSION\01"); @@ -816,7 +823,7 @@ TEST(IrcProtocolWithServer, SendMessagesWithEchoMessage) CHECK_NO_MSG; /* action on channel (with /ctcp <channel> action) */ - server_input_data (buffer_server, "/ctcp #test ACTION action chan 2"); + server_input_data (buffer_server, "/ctcp #test action action chan 2"); CHECK_SENT("PRIVMSG #test :\01ACTION action chan 2\01"); CHECK_NO_MSG; @@ -831,10 +838,15 @@ TEST(IrcProtocolWithServer, SendMessagesWithEchoMessage) CHECK_NO_MSG; /* action in private (with /ctcp) */ - server_input_data (buffer_server, "/ctcp bob ACTION action pv 2"); + server_input_data (buffer_server, "/ctcp bob action action pv 2"); CHECK_SENT("PRIVMSG bob :\01ACTION action pv 2\01"); CHECK_NO_MSG; + /* action in private (with /ctcp), without private buffer */ + server_input_data (buffer_server, "/ctcp bob2 action action pv 3"); + CHECK_SENT("PRIVMSG bob2 :\01ACTION action pv 3\01"); + CHECK_NO_MSG; + /* CTCP version to channel */ server_input_data (buffer_server, "/ctcp #test version"); CHECK_SENT("PRIVMSG #test :\01VERSION\01"); |