summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-command.c69
-rw-r--r--src/plugins/irc/irc-input.c69
-rw-r--r--src/plugins/irc/irc-input.h5
-rw-r--r--src/plugins/irc/irc-protocol.c98
4 files changed, 147 insertions, 94 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 2bced3a78..16727d4b9 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -3681,7 +3681,8 @@ IRC_COMMAND_CALLBACK(msg)
}
else
{
- irc_input_user_message_display (ptr_channel->buffer, 0,
+ irc_input_user_message_display (ptr_channel->buffer,
+ 0, 0, NULL, 0,
argv_eol[arg_text]);
irc_server_sendf (ptr_server,
IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
@@ -3712,36 +3713,13 @@ IRC_COMMAND_CALLBACK(msg)
{
if (ptr_channel2)
{
- if (status_msg)
- {
- /*
- * message to channel ops/voiced
- * (to "@#channel" or "+#channel")
- */
- string = irc_color_decode (
- argv_eol[arg_text],
- weechat_config_boolean (irc_config_network_colors_send));
- weechat_printf_date_tags (
- ptr_channel2->buffer,
- 0,
- "self_msg,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]);
- if (string)
- free (string);
- }
- else
- {
- /* standard message (to "#channel") */
- irc_input_user_message_display (ptr_channel2->buffer,
- 0, argv_eol[arg_text]);
- }
+ irc_input_user_message_display (
+ ptr_channel2->buffer,
+ 0, /* action */
+ 0, /* notice */
+ (status_msg) ? targets[i] : NULL,
+ is_channel,
+ argv_eol[arg_text]);
}
irc_server_sendf (ptr_server,
IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
@@ -3799,7 +3777,8 @@ IRC_COMMAND_CALLBACK(msg)
if (ptr_channel2)
{
irc_input_user_message_display (ptr_channel2->buffer,
- 0, argv_eol[arg_text]);
+ 0, 0, NULL, 0,
+ argv_eol[arg_text]);
}
else
{
@@ -3937,7 +3916,6 @@ IRC_COMMAND_CALLBACK(nick)
IRC_COMMAND_CALLBACK(notice)
{
- char *string;
const char *ptr_message;
int i, arg_target, arg_text, is_channel, list_size;
struct t_irc_channel *ptr_channel;
@@ -3986,27 +3964,15 @@ IRC_COMMAND_CALLBACK(notice)
for (i = 0; i < list_size; i++)
{
ptr_message = (const char *)weechat_arraylist_get (list_messages, i);
- string = irc_color_decode (
- ptr_message,
- weechat_config_boolean (irc_config_network_colors_send));
- weechat_printf_date_tags (
+ irc_input_user_message_display (
irc_msgbuffer_get_target_buffer (
ptr_server, argv[arg_target], "notice", NULL,
(ptr_channel) ? ptr_channel->buffer : NULL),
- 0,
- "self_msg,notify_none,no_highlight",
- "%s%s%s%s -> %s%s%s: %s",
- weechat_prefix ("network"),
- IRC_COLOR_NOTICE,
- /* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */
- _("Notice"),
- IRC_COLOR_RESET,
- (is_channel) ? IRC_COLOR_CHAT_CHANNEL : irc_nick_color_for_msg (ptr_server, 0, NULL, argv[arg_target]),
+ 0, /* action */
+ 1, /* notice */
argv[arg_target],
- IRC_COLOR_RESET,
- (string) ? string : ptr_message);
- if (string)
- free (string);
+ is_channel,
+ ptr_message);
}
weechat_arraylist_free (list_messages);
}
@@ -4524,7 +4490,8 @@ IRC_COMMAND_CALLBACK(query)
/* display text if given */
if (argv_eol[arg_text])
{
- irc_input_user_message_display (ptr_channel->buffer, 0,
+ irc_input_user_message_display (ptr_channel->buffer,
+ 0, 0, NULL, 0,
argv_eol[arg_text]);
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH,
NULL,
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index 68e5ae4c8..8a3a971df 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -41,10 +41,26 @@
* If action != 0, then message is displayed as an action (like command /me).
* If action == 0, but message is detected as an action (beginning with
* "\01ACTION "), then action is forced.
+ *
+ * If notice == 1, the message is a notice, otherwise it's a privmsg.
+ *
+ * If target is NULL, the message is displayed like this (standard message
+ * then action):
+ *
+ * nick | test
+ * * | nick is testing
+ *
+ * If target is not NULL, the message is displayed with the target, like this
+ * (privmsg then notice):
+ *
+ * Msg(nick) -> @#test: test message for ops
+ * Notice(nick) -> @#test: test notice for ops
*/
void
-irc_input_user_message_display (struct t_gui_buffer *buffer, int action,
+irc_input_user_message_display (struct t_gui_buffer *buffer,
+ int action, int notice,
+ const char *target, int target_is_channel,
const char *text)
{
struct t_irc_nick *ptr_nick;
@@ -92,9 +108,17 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, int action,
str_color = irc_color_for_tags (
weechat_config_color (
weechat_config_get ("weechat.color.chat_nick_self")));
- snprintf (str_tags, sizeof (str_tags),
- "self_msg,notify_none,no_highlight,prefix_nick_%s",
- (str_color) ? str_color : "default");
+ if (target)
+ {
+ snprintf (str_tags, sizeof (str_tags),
+ "self_msg,notify_none,no_highlight");
+ }
+ else
+ {
+ snprintf (str_tags, sizeof (str_tags),
+ "self_msg,notify_none,no_highlight,prefix_nick_%s",
+ (str_color) ? str_color : "default");
+ }
if (str_color)
free (str_color);
}
@@ -106,7 +130,7 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, int action,
0,
irc_protocol_tags (
ptr_server,
- "privmsg",
+ (notice) ? "notice" : "privmsg",
NULL,
str_tags,
(ptr_nick) ? ptr_nick->name : ptr_server->nick,
@@ -119,6 +143,38 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, int action,
IRC_COLOR_RESET,
ptr_text);
}
+ else if (target)
+ {
+ weechat_printf_date_tags (
+ buffer,
+ 0,
+ irc_protocol_tags (
+ ptr_server,
+ (notice) ? "notice" : "privmsg",
+ NULL,
+ str_tags,
+ (ptr_nick) ? ptr_nick->name : ptr_server->nick,
+ NULL),
+ "%s%s%s%s%s(%s%s%s%s)%s -> %s%s%s: %s",
+ weechat_prefix ("network"),
+ (notice) ? IRC_COLOR_NOTICE : "",
+ (notice) ?
+ /* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */
+ _("Notice") :
+ "Msg",
+ (notice) ? IRC_COLOR_RESET : "",
+ IRC_COLOR_CHAT_DELIMITERS,
+ irc_nick_mode_for_display (ptr_server, ptr_nick, 0),
+ IRC_COLOR_CHAT_NICK_SELF,
+ ptr_server->nick,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_RESET,
+ (target_is_channel) ?
+ IRC_COLOR_CHAT_CHANNEL : irc_nick_color_for_msg (ptr_server, 0, NULL, target),
+ target,
+ IRC_COLOR_RESET,
+ ptr_text);
+ }
else
{
weechat_printf_date_tags (
@@ -187,6 +243,9 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, int flags,
irc_input_user_message_display (
buffer,
action,
+ 0, /* notice */
+ NULL, /* target */
+ 0, /* target_is_channel */
(const char *)weechat_arraylist_get (list_messages, i));
}
weechat_arraylist_free (list_messages);
diff --git a/src/plugins/irc/irc-input.h b/src/plugins/irc/irc-input.h
index 8e8330737..fef8e93e7 100644
--- a/src/plugins/irc/irc-input.h
+++ b/src/plugins/irc/irc-input.h
@@ -23,7 +23,10 @@
struct t_gui_buffer;
extern void irc_input_user_message_display (struct t_gui_buffer *buffer,
- int action, const char *text);
+ int action, int notice,
+ const char *target,
+ int target_is_channel,
+ const char *text);
extern int irc_input_data_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
const char *input_data);
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index db3f6e040..6a7f184d6 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -2446,11 +2446,11 @@ IRC_PROTOCOL_CALLBACK(note)
IRC_PROTOCOL_CALLBACK(notice)
{
- char *notice_args, *pos, end_char, *channel, status_notice[2];
+ char *notice_args, *pos, end_char, *channel, str_tags[1024];
const char *pos_target, *pos_args, *nick_address;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
- int notify_private, is_channel, is_channel_orig;
+ int notify_private, is_channel, is_channel_orig, nick_is_me;
struct t_gui_buffer *ptr_buffer;
IRC_PROTOCOL_MIN_PARAMS(2);
@@ -2458,13 +2458,12 @@ IRC_PROTOCOL_CALLBACK(notice)
if (ignored)
return WEECHAT_RC_OK;
- status_notice[0] = '\0';
- status_notice[1] = '\0';
-
notice_args = irc_protocol_string_params (params, 1, num_params - 1);
if (!notice_args)
return WEECHAT_RC_ERROR;
+ nick_is_me = (irc_server_strcasecmp (server, server->nick, nick) == 0);
+
pos_args = notice_args;
pos_target = params[0];
@@ -2472,7 +2471,6 @@ IRC_PROTOCOL_CALLBACK(notice)
if (is_channel
&& irc_server_prefix_char_statusmsg (server, pos_target[0]))
{
- status_notice[0] = pos_target[0];
pos_target++;
}
@@ -2487,9 +2485,7 @@ IRC_PROTOCOL_CALLBACK(notice)
is_channel = irc_channel_is_channel (server, pos_target);
is_channel_orig = is_channel;
if (is_channel)
- {
channel = strdup (pos_target);
- }
else if (weechat_config_boolean (irc_config_look_notice_welcome_redirect))
{
end_char = ' ';
@@ -2547,29 +2543,40 @@ IRC_PROTOCOL_CALLBACK(notice)
}
ptr_nick = irc_nick_search (server, ptr_channel, nick);
+ if (nick_is_me)
+ {
+ snprintf (str_tags, sizeof (str_tags),
+ "self_msg,notify_none,no_highlight");
+ }
+ else
+ {
+ snprintf (str_tags, sizeof (str_tags),
+ "%s",
+ (is_channel_orig) ?
+ "notify_message" :
+ weechat_config_string (irc_config_look_notice_welcome_tags));
+ }
weechat_printf_date_tags (
(ptr_channel) ? ptr_channel->buffer : server->buffer,
date,
- irc_protocol_tags (server,
- command,
- tags,
- (is_channel_orig) ?
- "notify_message" :
- weechat_config_string (irc_config_look_notice_welcome_tags),
+ irc_protocol_tags (server, command, tags, str_tags,
nick, address),
- "%s%s%s%s%s%s%s(%s%s%s)%s: %s",
+ "%s%s%s%s%s(%s%s%s%s)%s%s%s%s%s: %s",
weechat_prefix ("network"),
IRC_COLOR_NOTICE,
(is_channel_orig) ? "" : "Pv",
/* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */
_("Notice"),
- (status_notice[0]) ? ":" : "",
- status_notice,
IRC_COLOR_CHAT_DELIMITERS,
+ irc_nick_mode_for_display (server, ptr_nick, 0),
irc_nick_color_for_msg (server, 0, ptr_nick, nick),
(nick && nick[0]) ? nick : "?",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
+ (is_channel_orig) ? " -> " : "",
+ (is_channel_orig) ? IRC_COLOR_CHAT_CHANNEL : "",
+ (is_channel_orig) ? params[0] : "",
+ (is_channel_orig) ? IRC_COLOR_RESET : "",
pos_args);
}
else
@@ -2956,9 +2963,9 @@ IRC_PROTOCOL_CALLBACK(pong)
IRC_PROTOCOL_CALLBACK(privmsg)
{
- char *msg_args, str_tags[1024], *str_color, status_msg[2], *color;
+ char *msg_args, str_tags[1024], *str_color, *color;
const char *pos_target, *remote_nick, *pv_tags;
- int is_channel, nick_is_me;
+ int status_msg, is_channel, nick_is_me;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
@@ -2972,9 +2979,10 @@ IRC_PROTOCOL_CALLBACK(privmsg)
if (!msg_args)
return WEECHAT_RC_ERROR;
- status_msg[0] = '\0';
- status_msg[1] = '\0';
+ nick_is_me = (irc_server_strcasecmp (server, server->nick, nick) == 0);
+
pos_target = params[0];
+ status_msg = 0;
is_channel = irc_channel_is_channel (server, pos_target);
if (!is_channel)
{
@@ -2982,7 +2990,7 @@ IRC_PROTOCOL_CALLBACK(privmsg)
&& irc_server_prefix_char_statusmsg (server, pos_target[0]))
{
is_channel = 1;
- status_msg[0] = pos_target[0];
+ status_msg = 1;
pos_target++;
}
}
@@ -3019,36 +3027,54 @@ IRC_PROTOCOL_CALLBACK(privmsg)
if (ptr_nick)
irc_nick_set_host (ptr_nick, address);
- if (status_msg[0])
+ if (status_msg)
{
/* message to channel ops/voiced (to "@#channel" or "+#channel") */
weechat_printf_date_tags (
ptr_channel->buffer,
date,
- irc_protocol_tags (server, command, tags, "notify_message",
- nick, address),
- "%s%s%s%s%s(%s%s%s)%s: %s",
+ irc_protocol_tags (
+ server, command, tags,
+ (nick_is_me) ?
+ "self_msg,notify_none,no_highlight" : "notify_message",
+ nick, address),
+ "%s%s%s(%s%s%s%s)%s -> %s%s%s: %s",
weechat_prefix ("network"),
"Msg",
- (status_msg[0]) ? ":" : "",
- status_msg,
IRC_COLOR_CHAT_DELIMITERS,
+ irc_nick_mode_for_display (server, ptr_nick, 0),
irc_nick_color_for_msg (server, 0, ptr_nick, nick),
(nick && nick[0]) ? nick : "?",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
+ IRC_COLOR_CHAT_CHANNEL,
+ params[0],
+ IRC_COLOR_RESET,
msg_args);
}
else
{
/* standard message (to "#channel") */
- color = irc_nick_find_color_name ((ptr_nick) ? ptr_nick->name : nick);
- str_color = irc_color_for_tags (color);
- if (color)
- free (color);
- snprintf (str_tags, sizeof (str_tags),
- "notify_message,prefix_nick_%s",
- (str_color) ? str_color : "default");
+ if (nick_is_me)
+ {
+ str_color = irc_color_for_tags (
+ weechat_config_color (
+ weechat_config_get ("weechat.color.chat_nick_self")));
+ snprintf (str_tags, sizeof (str_tags),
+ "self_msg,notify_none,no_highlight,prefix_nick_%s",
+ (str_color) ? str_color : "default");
+ }
+ else
+ {
+ color = irc_nick_find_color_name (
+ (ptr_nick) ? ptr_nick->name : nick);
+ str_color = irc_color_for_tags (color);
+ if (color)
+ free (color);
+ snprintf (str_tags, sizeof (str_tags),
+ "notify_message,prefix_nick_%s",
+ (str_color) ? str_color : "default");
+ }
if (str_color)
free (str_color);
weechat_printf_date_tags (
@@ -3075,8 +3101,6 @@ IRC_PROTOCOL_CALLBACK(privmsg)
}
else
{
- nick_is_me = (irc_server_strcasecmp (server, server->nick, nick) == 0);
-
remote_nick = (nick_is_me) ? pos_target : nick;
/* CTCP to user */