summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-10-16 18:24:33 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-10-17 21:28:31 +0200
commit96288d69e2d7fd5bebe21c846fc07311b985b350 (patch)
treeb0478b41c53045893a1b2141e70595f56ed7f7f8 /src
parentaad86a1955050db6dbfaceaed293dafd2799c3f9 (diff)
downloadweechat-96288d69e2d7fd5bebe21c846fc07311b985b350.zip
irc: use parsed command parameters in "367" command callback
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-protocol.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 74772f791..112cf0e53 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -5953,7 +5953,7 @@ IRC_PROTOCOL_CALLBACK(366)
* Callback for the IRC command "367": banlist.
*
* Command looks like:
- * :server 367 mynick #channel banmask nick!user@host 1205590879
+ * 367 mynick #channel banmask nick!user@host 1205590879
*/
IRC_PROTOCOL_CALLBACK(367)
@@ -5965,13 +5965,15 @@ IRC_PROTOCOL_CALLBACK(367)
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, 'b');
+ ptr_modelist = (ptr_channel) ?
+ irc_modelist_search (ptr_channel, 'b') : NULL;
+ str_number[0] = '\0';
if (ptr_modelist)
{
/* start receiving new list */
@@ -5988,19 +5990,20 @@ IRC_PROTOCOL_CALLBACK(367)
((ptr_modelist->last_item) ? ptr_modelist->last_item->number + 1 : 0) + 1,
IRC_COLOR_CHAT_DELIMITERS);
}
- 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, "banlist", ptr_buffer),
@@ -6011,11 +6014,11 @@ IRC_PROTOCOL_CALLBACK(367)
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));
@@ -6023,7 +6026,7 @@ IRC_PROTOCOL_CALLBACK(367)
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, "banlist", ptr_buffer),
@@ -6033,11 +6036,11 @@ IRC_PROTOCOL_CALLBACK(367)
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 : "?");
}
@@ -6045,7 +6048,7 @@ IRC_PROTOCOL_CALLBACK(367)
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, "banlist", ptr_buffer),
@@ -6055,11 +6058,11 @@ IRC_PROTOCOL_CALLBACK(367)
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);
}