1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 00:03:12 +02:00

irc: fix send of empty action with /me command

This commit is contained in:
Sébastien Helleu
2023-05-27 10:03:50 +02:00
parent be0b082463
commit 93d447ffc7
+42 -23
View File
@@ -1103,6 +1103,40 @@ irc_command_me_channel_display (struct t_irc_server *server,
free (string);
}
/*
* Sends a ctcp action to a channel for a single message
* (internal function called by irc_command_me_channel).
*/
void
irc_command_me_channel_message (struct t_irc_server *server,
struct t_irc_channel *channel,
const char *message)
{
struct t_arraylist *list_messages;
int i, list_size;
list_messages = irc_server_sendf (
server,
IRC_SERVER_SEND_OUTQ_PRIO_HIGH | IRC_SERVER_SEND_RETURN_LIST,
NULL,
"PRIVMSG %s :\01ACTION %s\01",
channel->name,
message);
if (list_messages)
{
list_size = weechat_arraylist_size (list_messages);
for (i = 0; i < list_size; i++)
{
irc_command_me_channel_display (
server,
channel,
(const char *)weechat_arraylist_get (list_messages, i));
}
weechat_arraylist_free (list_messages);
}
}
/*
* Sends a ctcp action to a channel.
*/
@@ -1112,37 +1146,22 @@ irc_command_me_channel (struct t_irc_server *server,
struct t_irc_channel *channel,
const char *arguments)
{
struct t_arraylist *list_messages;
char **list_arguments;
int i, j, list_size, count_arguments;
int i, count_arguments;
list_arguments = weechat_string_split ((arguments) ? arguments : "",
"\n", NULL, 0, 0, &count_arguments);
if (!list_arguments)
return;
for (i = 0; i < count_arguments; i++)
if (list_arguments)
{
list_messages = irc_server_sendf (
server,
IRC_SERVER_SEND_OUTQ_PRIO_HIGH | IRC_SERVER_SEND_RETURN_LIST,
NULL,
"PRIVMSG %s :\01ACTION %s\01",
channel->name,
list_arguments[i]);
if (list_messages)
for (i = 0; i < count_arguments; i++)
{
list_size = weechat_arraylist_size (list_messages);
for (j = 0; j < list_size; j++)
{
irc_command_me_channel_display (
server,
channel,
(const char *)weechat_arraylist_get (list_messages, j));
}
weechat_arraylist_free (list_messages);
irc_command_me_channel_message (server, channel, list_arguments[i]);
}
}
else
{
irc_command_me_channel_message (server, channel, "");
}
weechat_string_free_split (list_arguments);
}