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 "314" command callback

This commit is contained in:
Sébastien Helleu
2021-10-16 09:32:10 +02:00
parent 3c7d4b0516
commit e412a34668
2 changed files with 22 additions and 15 deletions
+15 -8
View File
@@ -4019,30 +4019,37 @@ IRC_PROTOCOL_CALLBACK(312)
* Callback for the IRC command "314": whowas.
*
* Command looks like:
* :server 314 mynick nick user host * :realname here
* 314 mynick nick user host * :realname here
*/
IRC_PROTOCOL_CALLBACK(314)
{
IRC_PROTOCOL_MIN_ARGS(8);
char *str_params;
IRC_PROTOCOL_MIN_PARAMS(6);
str_params = irc_protocol_string_params (params, 5, num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, argv[3], command, "whowas", NULL),
server, params[1], command, "whowas", NULL),
date,
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
_("%s%s[%s%s%s] (%s%s@%s%s)%s was %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, argv[3]),
argv[3],
irc_nick_color_for_msg (server, 1, NULL, params[1]),
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
argv[4],
argv[5],
params[2],
params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(argv_eol[7][0] == ':') ? argv_eol[7] + 1 : argv_eol[7]);
str_params);
if (str_params)
free (str_params);
return WEECHAT_RC_OK;
}
+7 -7
View File
@@ -2479,19 +2479,19 @@ TEST(IrcProtocolWithServer, 314)
{
SRV_INIT;
/* not enough arguments */
/* not enough parameters */
RECV(":server 314");
CHECK_ERROR_ARGS("314", 2, 8);
CHECK_ERROR_PARAMS("314", 0, 6);
RECV(":server 314 alice");
CHECK_ERROR_ARGS("314", 3, 8);
CHECK_ERROR_PARAMS("314", 1, 6);
RECV(":server 314 alice bob");
CHECK_ERROR_ARGS("314", 4, 8);
CHECK_ERROR_PARAMS("314", 2, 6);
RECV(":server 314 alice bob user");
CHECK_ERROR_ARGS("314", 5, 8);
CHECK_ERROR_PARAMS("314", 3, 6);
RECV(":server 314 alice bob user host");
CHECK_ERROR_ARGS("314", 6, 8);
CHECK_ERROR_PARAMS("314", 4, 6);
RECV(":server 314 alice bob user host *");
CHECK_ERROR_ARGS("314", 7, 8);
CHECK_ERROR_PARAMS("314", 5, 6);
RECV(":server 314 alice bob user host * :real name");
CHECK_SRV("-- [bob] (user@host) was real name");