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

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

This commit is contained in:
Sébastien Helleu
2021-10-16 09:42:25 +02:00
parent c577da0375
commit df9c32b0c3
2 changed files with 15 additions and 15 deletions
+11 -11
View File
@@ -4224,21 +4224,19 @@ IRC_PROTOCOL_CALLBACK(321)
* Callback for the IRC command "322": channel for /list.
*
* Command looks like:
* :server 322 mynick #channel 3 :topic of channel
* 322 mynick #channel 3 :topic of channel
*/
IRC_PROTOCOL_CALLBACK(322)
{
char *pos_topic;
char *str_params;
IRC_PROTOCOL_MIN_ARGS(5);
pos_topic = (argc > 5) ?
((argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]) : NULL;
IRC_PROTOCOL_MIN_PARAMS(3);
if (!server->cmd_list_regexp ||
(regexec (server->cmd_list_regexp, argv[3], 0, NULL, 0) == 0))
(regexec (server->cmd_list_regexp, params[1], 0, NULL, 0) == 0))
{
str_params = irc_protocol_string_params (params, 3, num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, "list", NULL),
@@ -4247,14 +4245,16 @@ IRC_PROTOCOL_CALLBACK(322)
"%s%s%s%s(%s%s%s)%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
argv[3],
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
argv[4],
params[2],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(pos_topic && pos_topic[0]) ? ": " : "",
(pos_topic && pos_topic[0]) ? pos_topic : "");
(str_params && str_params[0]) ? ": " : "",
(str_params && str_params[0]) ? str_params : "");
if (str_params)
free (str_params);
}
return WEECHAT_RC_OK;
+4 -4
View File
@@ -2589,13 +2589,13 @@ TEST(IrcProtocolWithServer, 322)
{
SRV_INIT;
/* not enough arguments */
/* not enough parameters */
RECV(":server 322");
CHECK_ERROR_ARGS("322", 2, 5);
CHECK_ERROR_PARAMS("322", 0, 3);
RECV(":server 322 alice");
CHECK_ERROR_ARGS("322", 3, 5);
CHECK_ERROR_PARAMS("322", 1, 3);
RECV(":server 322 alice #test");
CHECK_ERROR_ARGS("322", 4, 5);
CHECK_ERROR_PARAMS("322", 2, 3);
RECV(":server 322 alice #test 3");
CHECK_SRV("-- #test(3)");