mirror of
https://github.com/weechat/weechat.git
synced 2026-07-08 10:43:13 +02:00
irc: use parsed command parameters in "333" command callback
This commit is contained in:
@@ -4677,8 +4677,8 @@ IRC_PROTOCOL_CALLBACK(332)
|
||||
* Callback for the IRC command "333": infos about topic (nick / date).
|
||||
*
|
||||
* Command looks like:
|
||||
* :server 333 mynick #channel nick!user@host 1205428096
|
||||
* :server 333 mynick #channel 1205428096
|
||||
* 333 mynick #channel nick!user@host 1205428096
|
||||
* 333 mynick #channel 1205428096
|
||||
*/
|
||||
|
||||
IRC_PROTOCOL_CALLBACK(333)
|
||||
@@ -4687,21 +4687,19 @@ IRC_PROTOCOL_CALLBACK(333)
|
||||
struct t_irc_nick *ptr_nick;
|
||||
time_t datetime;
|
||||
const char *topic_nick, *topic_address;
|
||||
int arg_date;
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(5);
|
||||
IRC_PROTOCOL_MIN_PARAMS(3);
|
||||
|
||||
topic_nick = (argc > 5) ? irc_message_get_nick_from_host (argv[4]) : NULL;
|
||||
topic_address = (argc > 5) ? irc_message_get_address_from_host (argv[4]) : NULL;
|
||||
topic_nick = (num_params > 3) ? irc_message_get_nick_from_host (params[2]) : NULL;
|
||||
topic_address = (num_params > 3) ? irc_message_get_address_from_host (params[2]) : NULL;
|
||||
if (topic_nick && topic_address && strcmp (topic_nick, topic_address) == 0)
|
||||
topic_address = NULL;
|
||||
|
||||
ptr_channel = irc_channel_search (server, argv[3]);
|
||||
ptr_channel = irc_channel_search (server, params[1]);
|
||||
ptr_nick = (ptr_channel) ?
|
||||
irc_nick_search (server, ptr_channel, topic_nick) : NULL;
|
||||
arg_date = (argc > 5) ? 5 : 4;
|
||||
datetime = (time_t)(atol ((argv_eol[arg_date][0] == ':') ?
|
||||
argv_eol[arg_date] + 1 : argv_eol[arg_date]));
|
||||
datetime = (num_params > 3) ?
|
||||
(time_t)(atol (params[3])) : (time_t)(atol (params[2]));
|
||||
|
||||
if (!topic_nick && (datetime == 0))
|
||||
return WEECHAT_RC_OK;
|
||||
@@ -4759,7 +4757,7 @@ IRC_PROTOCOL_CALLBACK(333)
|
||||
_("%sTopic for %s%s%s set by %s%s%s%s%s%s%s%s%s on %s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
argv[3],
|
||||
params[1],
|
||||
IRC_COLOR_RESET,
|
||||
irc_nick_color_for_msg (server, 1, ptr_nick, topic_nick),
|
||||
topic_nick,
|
||||
@@ -4783,7 +4781,7 @@ IRC_PROTOCOL_CALLBACK(333)
|
||||
_("%sTopic for %s%s%s set on %s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
argv[3],
|
||||
params[1],
|
||||
IRC_COLOR_RESET,
|
||||
weechat_util_get_time_string (&datetime));
|
||||
}
|
||||
|
||||
@@ -2835,13 +2835,13 @@ TEST(IrcProtocolWithServer, 333)
|
||||
{
|
||||
SRV_INIT_JOIN;
|
||||
|
||||
/* not enough arguments */
|
||||
/* not enough parameters */
|
||||
RECV(":server 333");
|
||||
CHECK_ERROR_ARGS("333", 2, 5);
|
||||
CHECK_ERROR_PARAMS("333", 0, 3);
|
||||
RECV(":server 333 alice");
|
||||
CHECK_ERROR_ARGS("333", 3, 5);
|
||||
CHECK_ERROR_PARAMS("333", 1, 3);
|
||||
RECV(":server 333 alice #test");
|
||||
CHECK_ERROR_ARGS("333", 4, 5);
|
||||
CHECK_ERROR_PARAMS("333", 2, 3);
|
||||
|
||||
RECV(":server 333 alice #test nick!user@host");
|
||||
CHECK_NO_MSG;
|
||||
|
||||
Reference in New Issue
Block a user