irc: fix display of actions (/me) when they are received from a relay client (in channel and private buffers) (bug #38027)
This commit is contained in:
parent
323801f869
commit
faccb87a10
@ -1,7 +1,7 @@
|
||||
WeeChat ChangeLog
|
||||
=================
|
||||
Sébastien Helleu <flashcode@flashtux.org>
|
||||
v0.4.0-rc2, 2013-01-05
|
||||
v0.4.0-rc2, 2013-01-06
|
||||
|
||||
|
||||
Version 0.4.0 (under dev!)
|
||||
@ -71,6 +71,8 @@ Version 0.4.0 (under dev!)
|
||||
aspell.check.suggestions (task #12061)
|
||||
* aspell: fix creation of spellers when number of dictionaries is different
|
||||
between two buffers
|
||||
* irc: fix display of actions (/me) when they are received from a relay client
|
||||
(in channel and private buffers) (bug #38027)
|
||||
* irc: fix memory leak when updating modes of channel
|
||||
* irc: add tags "irc_nick1_xxx" and "irc_nick2_yyy" in message displayed for
|
||||
command "NICK"
|
||||
|
@ -2684,7 +2684,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
string = irc_color_decode (argv_eol[arg_text],
|
||||
weechat_config_boolean (irc_config_network_colors_receive));
|
||||
irc_input_user_message_display (ptr_channel->buffer,
|
||||
irc_input_user_message_display (ptr_channel->buffer, 0,
|
||||
(string) ? string : argv_eol[arg_text]);
|
||||
if (string)
|
||||
free (string);
|
||||
@ -2739,6 +2739,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
{
|
||||
/* standard message (to "#channel") */
|
||||
irc_input_user_message_display (ptr_channel->buffer,
|
||||
0,
|
||||
(string) ? string : argv_eol[arg_text]);
|
||||
}
|
||||
if (string)
|
||||
@ -2788,6 +2789,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
if (ptr_channel)
|
||||
{
|
||||
irc_input_user_message_display (ptr_channel->buffer,
|
||||
0,
|
||||
(string) ? string : argv_eol[arg_text]);
|
||||
}
|
||||
else
|
||||
@ -3474,7 +3476,7 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
{
|
||||
string = irc_color_decode (argv_eol[arg_text],
|
||||
weechat_config_boolean (irc_config_network_colors_receive));
|
||||
irc_input_user_message_display (ptr_channel->buffer,
|
||||
irc_input_user_message_display (ptr_channel->buffer, 0,
|
||||
(string) ? string : argv_eol[arg_text]);
|
||||
if (string)
|
||||
free (string);
|
||||
|
@ -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;
|
||||
|
||||
text_decoded = irc_color_decode (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 ((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);
|
||||
|
@ -23,7 +23,7 @@
|
||||
struct t_gui_buffer;
|
||||
|
||||
extern void irc_input_user_message_display (struct t_gui_buffer *buffer,
|
||||
const char *text);
|
||||
int action, const char *text);
|
||||
extern int irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
const char *input_data);
|
||||
extern int irc_input_send_cb (void *data, const char *signal,
|
||||
|
Loading…
x
Reference in New Issue
Block a user