From 3e602195e9205d070234155648c789b5a8f1eaea Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Wed, 14 Mar 2012 20:33:12 +0100 Subject: [PATCH] irc: display privmsg messages to "@#channel" and "+#channel" in channel buffer (bug #35331) --- ChangeLog | 4 +- src/plugins/irc/irc-command.c | 47 ++++++++++++++++++--- src/plugins/irc/irc-protocol.c | 75 +++++++++++++++++++++++++++------- 3 files changed, 104 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index daa82ab17..304075c3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu -v0.3.8-dev, 2012-03-13 +v0.3.8-dev, 2012-03-14 Version 0.3.8 (under dev!) @@ -15,6 +15,8 @@ Version 0.3.8 (under dev!) (task #11316) * core: fix display of wide chars on last column of chat area (patch #7733) * api: add list "gui_buffer_last_displayed" in hdata "buffer" +* irc: display privmsg messages to "@#channel" and "+#channel" in channel buffer + (bug #35331) * irc: fix redirection of message when message is queued for sending on server * irc: add signals and tags in messages for irc notify (task #11887) * irc: check notify immediately when adding a nick to notify list, improve diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 46c8baa90..1c85c27bc 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -2499,7 +2499,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { char **targets; - int num_targets, i, arg_target, arg_text; + int num_targets, i, arg_target, arg_text, is_channel, msg_op_voice; char *msg_pwd_hidden; char *string; @@ -2561,16 +2561,51 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, } else { - if (irc_channel_is_channel (ptr_server, targets[i])) + is_channel = 0; + ptr_channel = NULL; + msg_op_voice = 0; + if (((targets[i][0] == '@') || (targets[i][0] == '+')) + && irc_channel_is_channel (ptr_server, targets[i] + 1)) + { + ptr_channel = irc_channel_search (ptr_server, targets[i] + 1); + is_channel = 1; + msg_op_voice = 1; + } + else + { + ptr_channel = irc_channel_search (ptr_server, targets[i]); + if (ptr_channel) + is_channel = 1; + } + if (is_channel) { - ptr_channel = irc_channel_search (ptr_server, - targets[i]); if (ptr_channel) { string = irc_color_decode (argv_eol[arg_text], weechat_config_boolean (irc_config_network_colors_receive)); - irc_input_user_message_display (ptr_channel->buffer, - (string) ? string : argv_eol[arg_text]); + if (msg_op_voice) + { + /* + * message to channel ops/voiced + * (to "@#channel" or "+#channel") + */ + weechat_printf_tags (ptr_channel->buffer, + "notify_none,no_highlight", + "%s%s%s -> %s%s%s: %s", + weechat_prefix ("network"), + _("Msg"), + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + targets[i], + IRC_COLOR_RESET, + (string) ? string : argv_eol[arg_text]); + } + else + { + /* standard message (to "#channel") */ + irc_input_user_message_display (ptr_channel->buffer, + (string) ? string : argv_eol[arg_text]); + } if (string) free (string); } diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index f24e6c558..284b6a930 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -1450,9 +1450,9 @@ IRC_PROTOCOL_CALLBACK(pong) IRC_PROTOCOL_CALLBACK(privmsg) { - char *pos_args; + char *pos_args, *pos_target; const char *remote_nick; - int nick_is_me; + int msg_op, msg_voice, is_channel, nick_is_me; struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; @@ -1475,10 +1475,33 @@ IRC_PROTOCOL_CALLBACK(privmsg) pos_args = (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]; - /* receiver is a channel ? */ - if (irc_channel_is_channel (server, argv[2])) + msg_op = 0; + msg_voice = 0; + pos_target = argv[2]; + is_channel = irc_channel_is_channel (server, pos_target); + if (!is_channel) { - ptr_channel = irc_channel_search (server, argv[2]); + if (irc_channel_is_channel (server, pos_target + 1)) + { + if (pos_target[0] == '@') + { + is_channel = 1; + pos_target++; + msg_op = 1; + } + else if (pos_target[0] == '+') + { + is_channel = 1; + pos_target++; + msg_voice = 1; + } + } + } + + /* receiver is a channel ? */ + if (is_channel) + { + ptr_channel = irc_channel_search (server, pos_target); if (ptr_channel) { /* CTCP to channel */ @@ -1497,15 +1520,37 @@ IRC_PROTOCOL_CALLBACK(privmsg) if (ptr_nick && !ptr_nick->host) ptr_nick->host = strdup (address); - weechat_printf_tags (ptr_channel->buffer, - irc_protocol_tags (command, - "notify_message", - nick), - "%s%s", - irc_nick_as_prefix (server, ptr_nick, - (ptr_nick) ? NULL : nick, - NULL), - pos_args); + if (msg_op || msg_voice) + { + /* message to channel ops/voiced (to "@#channel" or "+#channel") */ + weechat_printf_tags (ptr_channel->buffer, + irc_protocol_tags (command, + "notify_message", + nick), + "%s%s%s%s(%s%s%s)%s: %s", + weechat_prefix ("network"), + _("Msg"), + (msg_op) ? "Op" : ((msg_voice) ? "Voice" : ""), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_message (server, ptr_nick, nick), + (nick && nick[0]) ? nick : "?", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + pos_args); + } + else + { + /* standard message (to "#channel") */ + weechat_printf_tags (ptr_channel->buffer, + irc_protocol_tags (command, + "notify_message", + nick), + "%s%s", + irc_nick_as_prefix (server, ptr_nick, + (ptr_nick) ? NULL : nick, + NULL), + pos_args); + } irc_channel_nick_speaking_add (ptr_channel, nick, @@ -1520,7 +1565,7 @@ IRC_PROTOCOL_CALLBACK(privmsg) { nick_is_me = (irc_server_strcasecmp (server, server->nick, nick) == 0); - remote_nick = (nick_is_me) ? argv[2] : nick; + remote_nick = (nick_is_me) ? pos_target : nick; /* CTCP to user */ if ((pos_args[0] == '\01')