summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-10-16 13:04:22 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-10-17 21:28:31 +0200
commit2ae974f5c38176f5e119bc0dcd252e0c34fd2aea (patch)
treece63ab826c688f629c46da4e24aa26f07ece9270
parent99d565f6df803dd4feb0ca2b4bcbcaeac2fe7ea3 (diff)
downloadweechat-2ae974f5c38176f5e119bc0dcd252e0c34fd2aea.zip
irc: use parsed command parameters in "346" command callback
-rw-r--r--src/plugins/irc/irc-protocol.c36
-rw-r--r--tests/unit/plugins/irc/test-irc-protocol.cpp8
2 files changed, 22 insertions, 22 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index df08e5664..51c47c0fd 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -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);
}
diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp
index e5a0fd685..d98133340 100644
--- a/tests/unit/plugins/irc/test-irc-protocol.cpp
+++ b/tests/unit/plugins/irc/test-irc-protocol.cpp
@@ -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");