From bf36f71b99b18401dbc6105509b0285146b37286 Mon Sep 17 00:00:00 2001 From: dequis Date: Tue, 22 Sep 2015 00:01:04 -0300 Subject: Fix #291, "/msg +#channel incorrectly shows up as Nick:@#channel" Just passing the full target to the "message irc op_public" signal handler and letting it do the cleanup. The fe_channel_skip_prefix() call in event_privmsg() is kept because recode_in() needs a real channel name, but There was similar code in sig_message_own_wall(), but that one is correct - the /wall command always sends NOTICE @#chan, so I added a comment down there to make it clear. --- src/fe-common/irc/fe-irc-messages.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/fe-common/irc/fe-irc-messages.c') diff --git a/src/fe-common/irc/fe-irc-messages.c b/src/fe-common/irc/fe-irc-messages.c index 11d158af..110fb29a 100644 --- a/src/fe-common/irc/fe-irc-messages.c +++ b/src/fe-common/irc/fe-irc-messages.c @@ -37,6 +37,7 @@ #include "fe-queries.h" #include "window-items.h" #include "fe-irc-channels.h" +#include "fe-irc-server.h" static void sig_message_own_public(SERVER_REC *server, const char *msg, const char *target, const char *origtarget) @@ -70,18 +71,28 @@ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg, const char *nick, const char *address, const char *target) { - char *nickmode, *optarget; + char *nickmode, *optarget, *prefix; + const char *cleantarget; + + /* only skip here so the difference can be stored in prefix */ + cleantarget = fe_channel_skip_prefix(IRC_SERVER(server), target); + prefix = g_strndup(target, cleantarget - target); + + /* and clean the rest here */ + cleantarget = get_visible_target(IRC_SERVER(server), cleantarget); nickmode = channel_get_nickmode(channel_find(server, target), nick); - optarget = g_strconcat("@", target, NULL); - printformat_module("fe-common/core", server, target, + optarget = g_strconcat(prefix, cleantarget, NULL); + + printformat_module("fe-common/core", server, cleantarget, MSGLEVEL_PUBLIC, TXT_PUBMSG_CHANNEL, nick, optarget, msg, nickmode); g_free(nickmode); - g_free(optarget); + g_free(optarget); + g_free(prefix); } static void sig_message_own_wall(SERVER_REC *server, const char *msg, @@ -92,7 +103,8 @@ static void sig_message_own_wall(SERVER_REC *server, const char *msg, nickmode = channel_get_nickmode(channel_find(server, target), server->nick); - optarget = g_strconcat("@", target, NULL); + /* this is always @, skip_prefix is not needed here */ + optarget = g_strconcat("@", target, NULL); printformat_module("fe-common/core", server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, -- cgit v1.2.3