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

This commit is contained in:
Sébastien Helleu
2021-10-16 11:47:09 +02:00
parent 0e9710de81
commit 741343e9aa
2 changed files with 16 additions and 18 deletions
+10 -14
View File
@@ -4834,32 +4834,28 @@ IRC_PROTOCOL_CALLBACK(338)
* Callback for the IRC command "341": inviting.
*
* Command looks like:
* :server 341 mynick nick #channel
* :server 341 mynick nick :#channel
* 341 mynick nick #channel
* 341 mynick nick :#channel
*/
IRC_PROTOCOL_CALLBACK(341)
{
char *pos_channel;
IRC_PROTOCOL_MIN_ARGS(5);
pos_channel = (argv[4][0] == ':') ? argv[4] + 1 : argv[4];
IRC_PROTOCOL_MIN_PARAMS(3);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, argv[2], command, NULL, NULL),
irc_msgbuffer_get_target_buffer (server, params[0], command, NULL, NULL),
date,
irc_protocol_tags (command, "irc_numeric", argv[2], address),
irc_protocol_tags (command, "irc_numeric", params[0], address),
_("%s%s%s%s has invited %s%s%s to %s%s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, NULL, argv[2]),
argv[2],
irc_nick_color_for_msg (server, 1, NULL, params[0]),
params[0],
IRC_COLOR_RESET,
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_RESET,
IRC_COLOR_CHAT_CHANNEL,
pos_channel,
params[2],
IRC_COLOR_RESET);
return WEECHAT_RC_OK;
+6 -4
View File
@@ -2892,16 +2892,18 @@ TEST(IrcProtocolWithServer, 341)
{
SRV_INIT;
/* not enough arguments */
/* not enough parameters */
RECV(":server 341");
CHECK_ERROR_ARGS("341", 2, 5);
CHECK_ERROR_PARAMS("341", 0, 3);
RECV(":server 341 alice");
CHECK_ERROR_ARGS("341", 3, 5);
CHECK_ERROR_PARAMS("341", 1, 3);
RECV(":server 341 alice bob");
CHECK_ERROR_ARGS("341", 4, 5);
CHECK_ERROR_PARAMS("341", 2, 3);
RECV(":server 341 alice bob #test");
CHECK_SRV("-- alice has invited bob to #test");
RECV(":server 341 alice bob :#test");
CHECK_SRV("-- alice has invited bob to #test");
}
/*