1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 22:36:38 +02:00

irc: display messages 730/731 even if command /notify was not used (closes #2049)

This commit is contained in:
Sébastien Helleu
2023-11-29 18:14:37 +01:00
parent 0f1b18d415
commit 22fcb91e8b
5 changed files with 129 additions and 33 deletions
+1
View File
@@ -47,6 +47,7 @@ Bug fixes::
* core: display an error on startup if environment variable "HOME" is not set
* core: fix crash when a custom bar item name is already used by a default bar item (issue #2034)
* core: fix random timeouts when a lot of concurrent processes are launched with hook_process (issue #2033)
* irc: display messages 730/731 (monitored nicks online/offline) even if command `/notify` was not used (issue #2049)
* irc: remove trailing "\r\n" in signals "irc_out" and "irc_outtags" when messages are queued
* irc: fix target buffer of IRC message 337 (whois reply: "is hiding their idle time")
* irc: revert compute of nick colors to case sensitive way, deprecate again infos "irc_nick_color" and "irc_nick_color_name" (issue #194, issue #2032)
+42 -23
View File
@@ -671,6 +671,45 @@ irc_notify_send_signal (struct t_irc_notify *notify,
free (data);
}
/*
* Display message about nick: "is connected", "is offline", "has connected",
* "has quit".
*
* If "notify" is NULL, only "is connected" or "is offline" can be displayed.
*/
void
irc_notify_display_is_on (struct t_irc_server *server,
const char *nick,
const char *host,
struct t_irc_notify *notify,
int is_on_server)
{
weechat_printf_date_tags (
server->buffer,
0,
irc_notify_get_tags (irc_config_look_notify_tags_ison,
(is_on_server) ? "join" : "quit",
nick),
(!notify || (notify->is_on_server < 0)) ?
((is_on_server) ?
_("%snotify: %s%s%s%s%s%s%s%s%s is connected") :
_("%snotify: %s%s%s%s%s%s%s%s%s is offline")) :
((is_on_server) ?
_("%snotify: %s%s%s%s%s%s%s%s%s has connected") :
_("%snotify: %s%s%s%s%s%s%s%s%s has quit")),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, NULL, nick),
nick,
(host && host[0]) ? IRC_COLOR_CHAT_DELIMITERS : "",
(host && host[0]) ? " (" : "",
(host && host[0]) ? IRC_COLOR_CHAT_HOST : "",
(host && host[0]) ? host : "",
(host && host[0]) ? IRC_COLOR_CHAT_DELIMITERS : "",
(host && host[0]) ? ")" : "",
(is_on_server) ? IRC_COLOR_MESSAGE_JOIN : IRC_COLOR_MESSAGE_QUIT);
}
/*
* Sets flag "is_on_server" for a notify and display message if user was not on
* server.
@@ -687,29 +726,9 @@ irc_notify_set_is_on_server (struct t_irc_notify *notify, const char *host,
if (notify->is_on_server == is_on_server)
return;
weechat_printf_date_tags (
notify->server->buffer,
0,
irc_notify_get_tags (irc_config_look_notify_tags_ison,
(is_on_server) ? "join" : "quit",
notify->nick),
(notify->is_on_server < 0) ?
((is_on_server) ?
_("%snotify: %s%s%s%s%s%s%s%s%s is connected") :
_("%snotify: %s%s%s%s%s%s%s%s%s is offline")) :
((is_on_server) ?
_("%snotify: %s%s%s%s%s%s%s%s%s has connected") :
_("%snotify: %s%s%s%s%s%s%s%s%s has quit")),
weechat_prefix ("network"),
irc_nick_color_for_msg (notify->server, 1, NULL, notify->nick),
notify->nick,
(host && host[0]) ? IRC_COLOR_CHAT_DELIMITERS : "",
(host && host[0]) ? " (" : "",
(host && host[0]) ? IRC_COLOR_CHAT_HOST : "",
(host && host[0]) ? host : "",
(host && host[0]) ? IRC_COLOR_CHAT_DELIMITERS : "",
(host && host[0]) ? ")" : "",
(is_on_server) ? IRC_COLOR_MESSAGE_JOIN : IRC_COLOR_MESSAGE_QUIT);
irc_notify_display_is_on (notify->server, notify->nick, host,
notify, is_on_server);
irc_notify_send_signal (notify, (is_on_server) ? "join" : "quit", NULL);
notify->is_on_server = is_on_server;
+5
View File
@@ -55,6 +55,11 @@ extern void irc_notify_new_for_server (struct t_irc_server *server);
extern void irc_notify_new_for_all_servers ();
extern void irc_notify_free (struct t_irc_server *server,
struct t_irc_notify *notify, int remove_monitor);
extern void irc_notify_display_is_on (struct t_irc_server *server,
const char *nick,
const char *host,
struct t_irc_notify *notify,
int is_on_server);
extern void irc_notify_set_is_on_server (struct t_irc_notify *notify,
const char *host, int is_on_server);
extern void irc_notify_free_all (struct t_irc_server *server);
+20
View File
@@ -7640,7 +7640,17 @@ IRC_PROTOCOL_CALLBACK(730)
monitor_host++;
ptr_notify = irc_notify_search (ctxt->server, monitor_nick);
if (ptr_notify)
{
irc_notify_set_is_on_server (ptr_notify, monitor_host, 1);
}
else
{
irc_notify_display_is_on (ctxt->server,
monitor_nick,
monitor_host,
NULL, /* notify */
1);
}
}
weechat_string_free_split (nicks);
}
@@ -7688,7 +7698,17 @@ IRC_PROTOCOL_CALLBACK(731)
monitor_host++;
ptr_notify = irc_notify_search (ctxt->server, monitor_nick);
if (ptr_notify)
{
irc_notify_set_is_on_server (ptr_notify, monitor_host, 0);
}
else
{
irc_notify_display_is_on (ctxt->server,
monitor_nick,
monitor_host,
NULL, /* notify */
0);
}
}
weechat_string_free_split (nicks);
}
+61 -10
View File
@@ -6017,29 +6017,80 @@ TEST(IrcProtocolWithServer, 730)
RECV(":server 731 alice");
CHECK_ERROR_PARAMS("731", 1, 2);
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_NO_MSG;
RECV(":server 731 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_NO_MSG;
/* with notify on nick1 */
run_cmd_quiet ("/notify add nick1 " IRC_FAKE_SERVER);
/* without notify */
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) is connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) is connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
RECV(":server 731 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) is offline",
"irc_notify,irc_notify_quit,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is offline",
"irc_notify,irc_notify_quit,nick_nick2,notify_message,log3");
RECV(":server 731 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) is offline",
"irc_notify,irc_notify_quit,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is offline",
"irc_notify,irc_notify_quit,nick_nick2,notify_message,log3");
/* with notify on nick1 */
run_cmd_quiet ("/notify add nick1 " IRC_FAKE_SERVER);
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) is connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
RECV(":server 731 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) has quit",
"irc_notify,irc_notify_quit,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is offline",
"irc_notify,irc_notify_quit,nick_nick2,notify_message,log3");
RECV(":server 731 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick2 (user2@host2) is offline",
"irc_notify,irc_notify_quit,nick_nick2,notify_message,log3");
/* with notify on nick1 and nick2 */
run_cmd_quiet ("/notify add nick2 " IRC_FAKE_SERVER);
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) has connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
run_cmd_quiet ("/mute /notify del nick1 " IRC_FAKE_SERVER);
/* with notify on nick1 and nick2 */
run_cmd_quiet ("/notify add nick1 " IRC_FAKE_SERVER);
run_cmd_quiet ("/notify add nick2 " IRC_FAKE_SERVER);
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) is connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
RECV(":server 731 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) has quit",
"irc_notify,irc_notify_quit,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) has quit",
"irc_notify,irc_notify_quit,nick_nick2,notify_message,log3");
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) has connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) has connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
run_cmd_quiet ("/mute /notify del nick1 " IRC_FAKE_SERVER);
run_cmd_quiet ("/mute /notify del nick2 " IRC_FAKE_SERVER);
}