1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

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

This commit is contained in:
Sébastien Helleu
2021-10-16 19:29:45 +02:00
parent baa91a45a8
commit a3ddeba9f9
2 changed files with 17 additions and 10 deletions
+12 -5
View File
@@ -6822,27 +6822,34 @@ IRC_PROTOCOL_CALLBACK(734)
* Callback for the IRC command "900": logged in as (SASL).
*
* Command looks like:
* :server 900 mynick nick!user@host mynick :You are now logged in as mynick
* 900 mynick nick!user@host mynick :You are now logged in as mynick
*/
IRC_PROTOCOL_CALLBACK(900)
{
IRC_PROTOCOL_MIN_ARGS(6);
char *str_params;
IRC_PROTOCOL_MIN_PARAMS(4);
str_params = irc_protocol_string_params (params, 3, num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, argv[3], command, NULL, NULL),
irc_msgbuffer_get_target_buffer (server, params[1], command, NULL, NULL),
date,
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
"%s%s %s(%s%s%s)",
weechat_prefix ("network"),
(argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5],
str_params,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
argv[3],
params[1],
IRC_COLOR_CHAT_DELIMITERS);
irc_server_free_sasl_data (server);
if (str_params)
free (str_params);
return WEECHAT_RC_OK;
}
+5 -5
View File
@@ -4004,15 +4004,15 @@ TEST(IrcProtocolWithServer, 900)
{
SRV_INIT;
/* not enough arguments */
/* not enough parameters */
RECV(":server 900");
CHECK_ERROR_ARGS("900", 2, 6);
CHECK_ERROR_PARAMS("900", 0, 4);
RECV(":server 900 alice");
CHECK_ERROR_ARGS("900", 3, 6);
CHECK_ERROR_PARAMS("900", 1, 4);
RECV(":server 900 alice alice!user@host");
CHECK_ERROR_ARGS("900", 4, 6);
CHECK_ERROR_PARAMS("900", 2, 4);
RECV(":server 900 alice alice!user@host alice");
CHECK_ERROR_ARGS("900", 5, 6);
CHECK_ERROR_PARAMS("900", 3, 4);
RECV(":server 900 alice alice!user@host alice logged");
CHECK_SRV("-- logged (alice!user@host)");