mirror of
https://github.com/weechat/weechat.git
synced 2026-07-03 08:13:14 +02:00
irc: fix display of message 350 (whois, gateway) (closes #1815)
This commit is contained in:
@@ -39,6 +39,7 @@ Bug fixes::
|
||||
* irc: display ACCOUNT and CHGHOST commands in private buffers
|
||||
* irc: fix extract of isupport value when it is last in list and without value (issue #1807)
|
||||
* irc: fix target buffer of generic errors when they contain a target nick (issue #1814)
|
||||
* irc: fix display of message 350 (whois, gateway) (issue #1815)
|
||||
* guile: fix function hdata_get_string
|
||||
* javascript: fix return of long value in functions infolist_time, hdata_long and hdata_time
|
||||
* php: fix function hdata_compare
|
||||
|
||||
@@ -5505,6 +5505,67 @@ IRC_PROTOCOL_CALLBACK(349)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for the IRC command "312": whois, gateway.
|
||||
*
|
||||
* Command looks like:
|
||||
* 350 mynick nick * * :is connected via the WebIRC gateway
|
||||
* 350 mynick nick real_hostname real_ip :is connected via the WebIRC gateway
|
||||
*/
|
||||
|
||||
IRC_PROTOCOL_CALLBACK(350)
|
||||
{
|
||||
char *str_params, str_host[1024];
|
||||
int has_real_hostmask, has_real_ip;
|
||||
|
||||
IRC_PROTOCOL_MIN_PARAMS(2);
|
||||
|
||||
if (num_params >= 5)
|
||||
{
|
||||
str_host[0] = '\0';
|
||||
has_real_hostmask = (strcmp (params[2], "*") != 0);
|
||||
has_real_ip = (strcmp (params[3], "*") != 0);
|
||||
if (has_real_hostmask || has_real_ip)
|
||||
{
|
||||
snprintf (str_host, sizeof (str_host),
|
||||
"%s(%s%s%s%s%s%s%s) ",
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_CHAT_HOST,
|
||||
(has_real_hostmask) ? params[2] : "",
|
||||
(has_real_hostmask && has_real_ip) ? IRC_COLOR_CHAT_DELIMITERS : "",
|
||||
(has_real_hostmask && has_real_ip) ? ", " : "",
|
||||
(has_real_hostmask && has_real_ip) ? IRC_COLOR_CHAT_HOST : "",
|
||||
(has_real_ip) ? params[3] : "",
|
||||
IRC_COLOR_CHAT_DELIMITERS);
|
||||
}
|
||||
str_params = irc_protocol_string_params (params, 4, num_params - 1);
|
||||
weechat_printf_date_tags (
|
||||
irc_msgbuffer_get_target_buffer (
|
||||
server, params[1], command, "whois", NULL),
|
||||
date,
|
||||
irc_protocol_tags (command, tags, NULL, NULL, NULL),
|
||||
"%s%s[%s%s%s] %s%s%s",
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
irc_nick_color_for_msg (server, 1, NULL, params[1]),
|
||||
params[1],
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
str_host,
|
||||
IRC_COLOR_RESET,
|
||||
str_params);
|
||||
if (str_params)
|
||||
free (str_params);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* not enough parameters: display with the default whois callback */
|
||||
IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for the IRC command "351": server version.
|
||||
*
|
||||
@@ -7311,6 +7372,7 @@ irc_protocol_recv_command (struct t_irc_server *server,
|
||||
IRCB(347, 1, 0, 347), /* end of invite list */
|
||||
IRCB(348, 1, 0, 348), /* channel exception list */
|
||||
IRCB(349, 1, 0, 349), /* end of channel exception list */
|
||||
IRCB(350, 1, 0, 350), /* whois (gateway) */
|
||||
IRCB(351, 1, 0, 351), /* server version */
|
||||
IRCB(352, 1, 0, 352), /* who */
|
||||
IRCB(353, 1, 0, 353), /* list of nicks on channel */
|
||||
|
||||
@@ -2526,13 +2526,13 @@ TEST(IrcProtocolWithServer, 311)
|
||||
CHECK_ERROR_PARAMS("311", 2, 3);
|
||||
RECV(":server 311 alice bob user");
|
||||
|
||||
/* standard parameters */
|
||||
RECV(":server 311 alice bob user host * :real name");
|
||||
CHECK_SRV("-- [bob] (user@host): real name");
|
||||
|
||||
/* non-standard parameters (using default whois callback) */
|
||||
RECV(":server 311 alice bob user");
|
||||
CHECK_SRV("-- [bob] user");
|
||||
|
||||
/* standard parameters */
|
||||
RECV(":server 311 alice bob user host * :real name");
|
||||
CHECK_SRV("-- [bob] (user@host): real name");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2552,13 +2552,13 @@ TEST(IrcProtocolWithServer, 312)
|
||||
RECV(":server 312 alice bob");
|
||||
CHECK_ERROR_PARAMS("312", 2, 3);
|
||||
|
||||
/* standard parameters */
|
||||
RECV(":server 312 alice bob server :https://example.com/");
|
||||
CHECK_SRV("-- [bob] server (https://example.com/)");
|
||||
|
||||
/* non-standard parameters (using default whois callback) */
|
||||
RECV(":server 312 alice bob server");
|
||||
CHECK_SRV("-- [bob] server");
|
||||
|
||||
/* standard parameters */
|
||||
RECV(":server 312 alice bob server :https://example.com/");
|
||||
CHECK_SRV("-- [bob] server (https://example.com/)");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2578,13 +2578,13 @@ TEST(IrcProtocolWithServer, 314)
|
||||
RECV(":server 314 alice bob");
|
||||
CHECK_ERROR_PARAMS("314", 2, 3);
|
||||
|
||||
/* standard parameters */
|
||||
RECV(":server 314 alice bob user host * :real name");
|
||||
CHECK_SRV("-- [bob] (user@host) was real name");
|
||||
|
||||
/* non-standard parameters (using default whowas callback) */
|
||||
RECV(":server 314 alice bob user");
|
||||
CHECK_SRV("-- [bob] user");
|
||||
|
||||
/* standard parameters */
|
||||
RECV(":server 314 alice bob user host * :real name");
|
||||
CHECK_SRV("-- [bob] (user@host) was real name");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2770,15 +2770,15 @@ TEST(IrcProtocolWithServer, 327)
|
||||
RECV(":server 327 alice bob");
|
||||
CHECK_ERROR_PARAMS("327", 2, 3);
|
||||
|
||||
/* non-standard parameters (using default whois callback) */
|
||||
RECV(":server 327 alice bob host");
|
||||
CHECK_SRV("-- [bob] host");
|
||||
|
||||
/* standard parameters */
|
||||
RECV(":server 327 alice bob host 1.2.3.4");
|
||||
CHECK_SRV("-- [bob] host 1.2.3.4");
|
||||
RECV(":server 327 alice bob host 1.2.3.4 :real name");
|
||||
CHECK_SRV("-- [bob] host 1.2.3.4 (real name)");
|
||||
|
||||
/* non-standard parameters (using default whois callback) */
|
||||
RECV(":server 327 alice bob host");
|
||||
CHECK_SRV("-- [bob] host");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3200,6 +3200,43 @@ TEST(IrcProtocolWithServer, 349)
|
||||
CHECK_SRV("-- [#xyz] End of Channel Exception List");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* irc_protocol_cb_350 (whois, gateway)
|
||||
*/
|
||||
|
||||
TEST(IrcProtocolWithServer, 350)
|
||||
{
|
||||
SRV_INIT_JOIN;
|
||||
|
||||
/* not enough parameters */
|
||||
RECV(":server 350");
|
||||
CHECK_ERROR_PARAMS("350", 0, 2);
|
||||
RECV(":server 350 alice");
|
||||
CHECK_ERROR_PARAMS("350", 1, 2);
|
||||
|
||||
/* non-standard parameters (using whois_nick_msg callback) */
|
||||
RECV(":server 350 alice bob :something here");
|
||||
CHECK_SRV("-- [bob] something here");
|
||||
RECV(":server 350 alice bob * :something here");
|
||||
CHECK_SRV("-- [bob] * something here");
|
||||
|
||||
/* non-standard parameters (using default whois callback) */
|
||||
RECV(":server 350 alice bob");
|
||||
CHECK_SRV("-- bob");
|
||||
|
||||
/* standard parameters */
|
||||
RECV(":server 350 alice bob * * :is connected via the WebIRC gateway");
|
||||
CHECK_SRV("-- [bob] is connected via the WebIRC gateway");
|
||||
RECV(":server 350 alice bob example.com * :is connected via the WebIRC gateway");
|
||||
CHECK_SRV("-- [bob] (example.com) is connected via the WebIRC gateway");
|
||||
RECV(":server 350 alice bob * 1.2.3.4 :is connected via the WebIRC gateway");
|
||||
CHECK_SRV("-- [bob] (1.2.3.4) is connected via the WebIRC gateway");
|
||||
RECV(":server 350 alice bob example.com 1.2.3.4 :is connected via the WebIRC gateway");
|
||||
CHECK_SRV("-- [bob] (example.com, 1.2.3.4) is connected via the WebIRC gateway");
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* irc_protocol_cb_351 (server version)
|
||||
|
||||
Reference in New Issue
Block a user