mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
irc: display commands 716/717 in private buffer (if present) (closes #146)
Commands 716/717 are returned if the target user has mode +g, they look like this: :server 716 my_nick bob :is in +g mode and must manually allow you to message them. Your message was discarded. :server 717 my_nick bob :has been informed that you messaged them.
This commit is contained in:
@@ -17,6 +17,7 @@ New features::
|
||||
|
||||
* core: add variables "_chat_focused_line_bol" and "_chat_focused_line_eol" in focus data (issue #1955)
|
||||
* api: add info "buffer" (issue #1962)
|
||||
* irc: display commands 716/717 in private buffer (if present) (issue #146)
|
||||
|
||||
Bug fixes::
|
||||
|
||||
|
||||
@@ -1517,7 +1517,7 @@ IRC_PROTOCOL_CALLBACK(generic_error)
|
||||
int arg_error, force_server_buffer;
|
||||
char *str_error, str_target[512];
|
||||
const char *pos_channel, *pos_nick;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_channel *ptr_channel, *ptr_channel2;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
IRC_PROTOCOL_MIN_PARAMS(2);
|
||||
@@ -1530,17 +1530,18 @@ IRC_PROTOCOL_CALLBACK(generic_error)
|
||||
pos_nick = NULL;
|
||||
str_target[0] = '\0';
|
||||
|
||||
/*
|
||||
* force display on server buffer for these messages:
|
||||
* - 432: erroneous nickname
|
||||
* - 433: nickname already in use
|
||||
* - 437: nick/channel temporarily unavailable
|
||||
*/
|
||||
force_server_buffer = ((strcmp (command, "432") == 0)
|
||||
|| (strcmp (command, "433") == 0)
|
||||
|| (strcmp (command, "437") == 0));
|
||||
|
||||
if (params[arg_error + 1])
|
||||
{
|
||||
/*
|
||||
* force display on server buffer for these messages:
|
||||
* - 432: erroneous nickname
|
||||
* - 433: nickname already in use
|
||||
* - 437: nick/channel temporarily unavailable
|
||||
*/
|
||||
force_server_buffer = ((strcmp (command, "432") == 0)
|
||||
|| (strcmp (command, "433") == 0)
|
||||
|| (strcmp (command, "437") == 0));
|
||||
if (!force_server_buffer
|
||||
&& irc_channel_is_channel (server, params[arg_error]))
|
||||
{
|
||||
@@ -1565,7 +1566,19 @@ IRC_PROTOCOL_CALLBACK(generic_error)
|
||||
}
|
||||
}
|
||||
|
||||
ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
|
||||
ptr_buffer = NULL;
|
||||
if (ptr_channel)
|
||||
{
|
||||
ptr_buffer = ptr_channel->buffer;
|
||||
}
|
||||
else if (!force_server_buffer && pos_nick)
|
||||
{
|
||||
ptr_channel2 = irc_channel_search (server, pos_nick);
|
||||
if (ptr_channel2)
|
||||
ptr_buffer = ptr_channel2->buffer;
|
||||
}
|
||||
if (!ptr_buffer)
|
||||
ptr_buffer = server->buffer;
|
||||
|
||||
str_error = irc_protocol_string_params (params, arg_error, num_params - 1);
|
||||
|
||||
@@ -7897,6 +7910,8 @@ irc_protocol_recv_command (struct t_irc_server *server,
|
||||
IRCB(712, 1, 0, knock_reply), /* knock: too many knocks */
|
||||
IRCB(713, 1, 0, knock_reply), /* knock: channel is open */
|
||||
IRCB(714, 1, 0, knock_reply), /* knock: already on that channel */
|
||||
IRCB(716, 1, 0, generic_error), /* nick is in +g mode */
|
||||
IRCB(717, 1, 0, generic_error), /* nick has been informed of msg */
|
||||
IRCB(728, 1, 0, 728), /* quietlist */
|
||||
IRCB(729, 1, 0, 729), /* end of quietlist */
|
||||
IRCB(730, 1, 0, 730), /* monitored nicks online */
|
||||
|
||||
@@ -5357,7 +5357,7 @@ TEST(IrcProtocolWithServer, 433_connected)
|
||||
* never happen in practice): check that the message is still displayed
|
||||
* on the server buffer
|
||||
*/
|
||||
RECV(":server 433 alice #test :Nickname is already in use.");
|
||||
RECV(":server 433 alice #test :Nickname is already in use.");
|
||||
CHECK_SRV("--", "#test: Nickname is already in use.",
|
||||
"irc_433,irc_numeric,log3");
|
||||
}
|
||||
@@ -5666,6 +5666,66 @@ TEST(IrcProtocolWithServer, 714)
|
||||
"irc_714,irc_numeric,log3");
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* irc_protocol_cb_716 (nick is in +g mode)
|
||||
*/
|
||||
|
||||
TEST(IrcProtocolWithServer, 716)
|
||||
{
|
||||
SRV_INIT_JOIN;
|
||||
|
||||
/* not enough parameters */
|
||||
RECV(":server 716");
|
||||
CHECK_ERROR_PARAMS("716", 0, 2);
|
||||
RECV(":server 716 alice");
|
||||
CHECK_ERROR_PARAMS("716", 1, 2);
|
||||
|
||||
RECV(":server 716 alice bob :is in +g mode and must manually allow you to "
|
||||
"message them. Your message was discarded.");
|
||||
CHECK_SRV("--",
|
||||
"bob: is in +g mode and must manually allow you to message them. "
|
||||
"Your message was discarded.",
|
||||
"irc_716,irc_numeric,log3");
|
||||
|
||||
/* open private buffer */
|
||||
RECV(":bob!user@host PRIVMSG alice :hi Alice!");
|
||||
|
||||
RECV(":server 716 alice bob :is in +g mode and must manually allow you to "
|
||||
"message them. Your message was discarded.");
|
||||
CHECK_PV("bob", "--",
|
||||
"bob: is in +g mode and must manually allow you to message them. "
|
||||
"Your message was discarded.",
|
||||
"irc_716,irc_numeric,log3");
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* irc_protocol_cb_717 (nick has been informed that you messaged them)
|
||||
*/
|
||||
|
||||
TEST(IrcProtocolWithServer, 717)
|
||||
{
|
||||
SRV_INIT_JOIN;
|
||||
|
||||
/* not enough parameters */
|
||||
RECV(":server 717");
|
||||
CHECK_ERROR_PARAMS("717", 0, 2);
|
||||
RECV(":server 717 alice");
|
||||
CHECK_ERROR_PARAMS("717", 1, 2);
|
||||
|
||||
RECV(":server 717 alice bob :has been informed that you messaged them.");
|
||||
CHECK_SRV("--", "bob: has been informed that you messaged them.",
|
||||
"irc_717,irc_numeric,log3");
|
||||
|
||||
/* open private buffer */
|
||||
RECV(":bob!user@host PRIVMSG alice :hi Alice!");
|
||||
RECV(":server 717 alice bob :has been informed that you messaged them.");
|
||||
CHECK_PV("bob", "--",
|
||||
"bob: has been informed that you messaged them.",
|
||||
"irc_717,irc_numeric,log3");
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* irc_protocol_cb_728 (quietlist)
|
||||
|
||||
Reference in New Issue
Block a user