1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 21:06:38 +02:00

irc: use parsed command parameters in "346" command callback

This commit is contained in:
Sébastien Helleu
2021-10-16 13:04:22 +02:00
parent 99d565f6df
commit 2ae974f5c3
2 changed files with 22 additions and 22 deletions
+18 -18
View File
@@ -4930,8 +4930,8 @@ IRC_PROTOCOL_CALLBACK(345)
* Callback for the IRC command "346": channel invite list.
*
* Command looks like:
* :server 346 mynick #channel invitemask nick!user@host 1205590879
* :server 346 mynick #channel invitemask
* 346 mynick #channel invitemask nick!user@host 1205590879
* 346 mynick #channel invitemask
*/
IRC_PROTOCOL_CALLBACK(346)
@@ -4943,9 +4943,9 @@ IRC_PROTOCOL_CALLBACK(346)
const char *nick_address;
char str_number[64];
IRC_PROTOCOL_MIN_ARGS(5);
IRC_PROTOCOL_MIN_PARAMS(3);
ptr_channel = irc_channel_search (server, argv[3]);
ptr_channel = irc_channel_search (server, params[1]);
ptr_buffer = (ptr_channel && ptr_channel->nicks) ?
ptr_channel->buffer : server->buffer;
ptr_modelist = irc_modelist_search (ptr_channel, 'I');
@@ -4969,16 +4969,16 @@ IRC_PROTOCOL_CALLBACK(346)
else
str_number[0] = '\0';
if (argc >= 6)
if (num_params >= 4)
{
nick_address = irc_protocol_nick_address (
server, 1, NULL, irc_message_get_nick_from_host (argv[5]),
irc_message_get_address_from_host (argv[5]));
if (argc >= 7)
server, 1, NULL, irc_message_get_nick_from_host (params[3]),
irc_message_get_address_from_host (params[3]));
if (num_params >= 5)
{
datetime = (time_t)(atol ((argv[6][0] == ':') ? argv[6] + 1 : argv[6]));
datetime = (time_t)(atol (params[4]));
if (ptr_modelist)
irc_modelist_item_new (ptr_modelist, argv[4], argv[5], datetime);
irc_modelist_item_new (ptr_modelist, params[2], params[3], datetime);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, "invitelist", ptr_buffer),
@@ -4989,11 +4989,11 @@ IRC_PROTOCOL_CALLBACK(346)
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
argv[4],
params[2],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?",
weechat_util_get_time_string (&datetime));
@@ -5001,7 +5001,7 @@ IRC_PROTOCOL_CALLBACK(346)
else
{
if (ptr_modelist)
irc_modelist_item_new (ptr_modelist, argv[4], argv[5], 0);
irc_modelist_item_new (ptr_modelist, params[2], params[3], 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, "invitelist", ptr_buffer),
@@ -5011,11 +5011,11 @@ IRC_PROTOCOL_CALLBACK(346)
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
argv[4],
params[2],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?");
}
@@ -5023,7 +5023,7 @@ IRC_PROTOCOL_CALLBACK(346)
else
{
if (ptr_modelist)
irc_modelist_item_new (ptr_modelist, argv[4], NULL, 0);
irc_modelist_item_new (ptr_modelist, params[2], NULL, 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, "invitelist", ptr_buffer),
@@ -5033,11 +5033,11 @@ IRC_PROTOCOL_CALLBACK(346)
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
argv[4],
params[2],
IRC_COLOR_RESET);
}
+4 -4
View File
@@ -2973,13 +2973,13 @@ TEST(IrcProtocolWithServer, 346)
{
SRV_INIT_JOIN;
/* not enough arguments */
/* not enough parameters */
RECV(":server 346");
CHECK_ERROR_ARGS("346", 2, 5);
CHECK_ERROR_PARAMS("346", 0, 3);
RECV(":server 346 alice");
CHECK_ERROR_ARGS("346", 3, 5);
CHECK_ERROR_PARAMS("346", 1, 3);
RECV(":server 346 alice #test");
CHECK_ERROR_ARGS("346", 4, 5);
CHECK_ERROR_PARAMS("346", 2, 3);
RECV(":server 346 alice #test invitemask");
CHECK_CHAN("-- [#test] [1] invitemask invited");