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:
@@ -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;
|
||||
|
||||
@@ -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)");
|
||||
|
||||
Reference in New Issue
Block a user