mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 00:05:41 +02:00
irc: use parsed command parameters in "numeric" command callback
This commit is contained in:
@@ -3138,21 +3138,17 @@ IRC_PROTOCOL_CALLBACK(server_mode_reason)
|
||||
|
||||
IRC_PROTOCOL_CALLBACK(numeric)
|
||||
{
|
||||
char *pos_args;
|
||||
int arg_text;
|
||||
char *str_params;
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(3);
|
||||
IRC_PROTOCOL_MIN_PARAMS(1);
|
||||
|
||||
if (irc_server_strcasecmp (server, server->nick, argv[2]) == 0)
|
||||
{
|
||||
pos_args = (argc > 3) ?
|
||||
((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos_args = (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2];
|
||||
}
|
||||
arg_text = (irc_server_strcasecmp (server, server->nick, params[0]) == 0) ?
|
||||
1 : 0;
|
||||
|
||||
if (pos_args)
|
||||
str_params = irc_protocol_string_params (params, arg_text, num_params - 1);
|
||||
|
||||
if (str_params && str_params[0])
|
||||
{
|
||||
weechat_printf_date_tags (
|
||||
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
|
||||
@@ -3160,9 +3156,12 @@ IRC_PROTOCOL_CALLBACK(numeric)
|
||||
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
|
||||
"%s%s",
|
||||
weechat_prefix ("network"),
|
||||
pos_args);
|
||||
str_params);
|
||||
}
|
||||
|
||||
if (str_params)
|
||||
free (str_params);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -579,7 +579,7 @@ TEST(IrcProtocolWithServer, recv_command_not_found)
|
||||
"abc def\"");
|
||||
|
||||
RECV(":alice!user@host 099");
|
||||
CHECK_ERROR_ARGS("099", 2, 3);
|
||||
CHECK_ERROR_PARAMS("099", 0, 1);
|
||||
|
||||
RECV(":alice!user@host 099 abc def");
|
||||
CHECK_SRV("-- abc def");
|
||||
@@ -3762,13 +3762,13 @@ TEST(IrcProtocolWithServer, 903_907)
|
||||
{
|
||||
SRV_INIT;
|
||||
|
||||
/* not enough arguments */
|
||||
/* not enough parameters */
|
||||
RECV(":server 903");
|
||||
CHECK_ERROR_ARGS("903", 2, 3);
|
||||
CHECK_ERROR_PARAMS("903", 0, 1);
|
||||
|
||||
/* not enough arguments */
|
||||
/* not enough parameters */
|
||||
RECV(":server 907");
|
||||
CHECK_ERROR_ARGS("907", 2, 3);
|
||||
CHECK_ERROR_PARAMS("907", 0, 1);
|
||||
|
||||
RECV(":server 903 alice ok");
|
||||
CHECK_SRV("-- ok");
|
||||
@@ -3793,21 +3793,21 @@ TEST(IrcProtocolWithServer, 902_904_905_906)
|
||||
{
|
||||
SRV_INIT;
|
||||
|
||||
/* not enough arguments */
|
||||
/* not enough parameters */
|
||||
RECV(":server 902");
|
||||
CHECK_ERROR_ARGS("902", 2, 3);
|
||||
CHECK_ERROR_PARAMS("902", 0, 1);
|
||||
|
||||
/* not enough arguments */
|
||||
/* not enough parameters */
|
||||
RECV(":server 904");
|
||||
CHECK_ERROR_ARGS("904", 2, 3);
|
||||
CHECK_ERROR_PARAMS("904", 0, 1);
|
||||
|
||||
/* not enough arguments */
|
||||
/* not enough parameters */
|
||||
RECV(":server 905");
|
||||
CHECK_ERROR_ARGS("905", 2, 3);
|
||||
CHECK_ERROR_PARAMS("905", 0, 1);
|
||||
|
||||
/* not enough arguments */
|
||||
/* not enough parameters */
|
||||
RECV(":server 906");
|
||||
CHECK_ERROR_ARGS("906", 2, 3);
|
||||
CHECK_ERROR_PARAMS("906", 0, 1);
|
||||
|
||||
RECV(":server 902 alice error");
|
||||
CHECK_SRV("-- error");
|
||||
|
||||
Reference in New Issue
Block a user