summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-input.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/irc/irc-input.c')
-rw-r--r--src/plugins/irc/irc-input.c90
1 files changed, 69 insertions, 21 deletions
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index b1fa34d75..ddd13cc00 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -37,15 +37,34 @@
/*
* Displays user message.
+ *
+ * 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.
*/
void
-irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
+irc_input_user_message_display (struct t_gui_buffer *buffer, int action,
+ const char *text)
{
struct t_irc_nick *ptr_nick;
- char *text_decoded, str_tags[256], *str_color;
+ char *pos, *text2, *text_decoded, str_tags[256], *str_color;
+ const char *ptr_text;
+
+ /* if message is an action, force "action" to 1 and extract message */
+ if (strncmp (text, "\01ACTION ", 8) == 0)
+ {
+ action = 1;
+ pos = strchr (text + 8, '\01');
+ if (pos)
+ text2 = weechat_strndup (text + 8, pos - text - 8);
+ else
+ text2 = strdup (text + 8);
+ }
+ else
+ text2 = strdup (text);
- text_decoded = irc_color_decode (text,
+ text_decoded = irc_color_decode ((text2) ? text2 : text,
weechat_config_boolean (irc_config_network_colors_send));
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
@@ -59,24 +78,52 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
ptr_server->nick);
}
- str_color = irc_color_for_tags (weechat_config_color (weechat_config_get ("weechat.color.chat_nick_self")));
- snprintf (str_tags, sizeof (str_tags),
- "notify_none,no_highlight,prefix_nick_%s",
- (str_color) ? str_color : "default");
- if (str_color)
- free (str_color);
- weechat_printf_tags (buffer,
- irc_protocol_tags ("privmsg",
- str_tags,
- (ptr_nick) ? ptr_nick->name : ptr_server->nick),
- "%s%s",
- irc_nick_as_prefix (ptr_server,
- (ptr_nick) ? ptr_nick : NULL,
- (ptr_nick) ? NULL : ptr_server->nick,
- IRC_COLOR_CHAT_NICK_SELF),
- (text_decoded) ? text_decoded : text);
+ if (action)
+ {
+ snprintf (str_tags, sizeof (str_tags),
+ "irc_action,notify_none,no_highlight");
+ }
+ else
+ {
+ str_color = irc_color_for_tags (weechat_config_color (weechat_config_get ("weechat.color.chat_nick_self")));
+ snprintf (str_tags, sizeof (str_tags),
+ "notify_none,no_highlight,prefix_nick_%s",
+ (str_color) ? str_color : "default");
+ if (str_color)
+ free (str_color);
+ }
+ ptr_text = (text_decoded) ? text_decoded : ((text2) ? text2 : text);
+ if (action)
+ {
+ weechat_printf_tags (buffer,
+ irc_protocol_tags ("privmsg",
+ str_tags,
+ (ptr_nick) ? ptr_nick->name : ptr_server->nick),
+ "%s%s%s%s%s %s",
+ weechat_prefix ("action"),
+ irc_nick_mode_for_display (ptr_server, ptr_nick, 0),
+ IRC_COLOR_CHAT_NICK_SELF,
+ ptr_server->nick,
+ IRC_COLOR_RESET,
+ ptr_text);
+ }
+ else
+ {
+ weechat_printf_tags (buffer,
+ irc_protocol_tags ("privmsg",
+ str_tags,
+ (ptr_nick) ? ptr_nick->name : ptr_server->nick),
+ "%s%s",
+ irc_nick_as_prefix (ptr_server,
+ (ptr_nick) ? ptr_nick : NULL,
+ (ptr_nick) ? NULL : ptr_server->nick,
+ IRC_COLOR_CHAT_NICK_SELF),
+ ptr_text);
+ }
}
+ if (text2)
+ free (text2);
if (text_decoded)
free (text_decoded);
}
@@ -91,7 +138,7 @@ void
irc_input_send_user_message (struct t_gui_buffer *buffer, int flags,
const char *tags, char *message)
{
- int number;
+ int number, action;
char hash_key[32], *str_args;
struct t_hashtable *hashtable;
@@ -114,6 +161,7 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, int flags,
ptr_channel->name, message);
if (hashtable)
{
+ action = (strncmp (message, "\01ACTION ", 8) == 0);
number = 1;
while (1)
{
@@ -121,7 +169,7 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, int flags,
str_args = weechat_hashtable_get (hashtable, hash_key);
if (!str_args)
break;
- irc_input_user_message_display (buffer, str_args);
+ irc_input_user_message_display (buffer, action, str_args);
number++;
}
weechat_hashtable_free (hashtable);