summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-08-13 22:58:37 +0200
committerSébastien Helleu <flashcode@flashtux.org>2022-08-13 22:58:37 +0200
commit223eefef67675e78d7eae550e7bcc26c4fa5332f (patch)
treee0331a281f14be510607fdc4e17ca42333120140
parentaee3da54524a52a52573be2fd0777bbf43acc179 (diff)
downloadweechat-223eefef67675e78d7eae550e7bcc26c4fa5332f.zip
irc: display ACCOUNT command in private buffers
-rw-r--r--ChangeLog.adoc2
-rw-r--r--src/plugins/irc/irc-protocol.c99
-rw-r--r--tests/unit/plugins/irc/test-irc-protocol.cpp28
3 files changed, 81 insertions, 48 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index aef97ec4e..eff19d0f9 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -34,7 +34,7 @@ Bug fixes::
* irc: fix display of TOPIC and QUIT messages with an empty trailing parameter (issue #1797)
* irc: fix parsing of messages with trailing spaces and no trailing parameter (issue #1803)
* irc: add missing tag "irc_numeric" in all numeric IRC commands (issue #1804)
- * irc: display CHGHOST command in private buffers
+ * irc: display ACCOUNT and CHGHOST commands in private buffers
* 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
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index f19b95c51..5c1b314c2 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -437,41 +437,68 @@ IRC_PROTOCOL_CALLBACK(account)
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
- if (ptr_nick)
+ switch (ptr_channel->type)
{
- if (!ignored
- && weechat_config_boolean (irc_config_look_display_account_message))
- {
- ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter))
- && (weechat_config_boolean (irc_config_look_smart_filter_account))) ?
- irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL;
- smart_filter = (!local_account
- && weechat_config_boolean (irc_config_look_smart_filter)
- && weechat_config_boolean (irc_config_look_smart_filter_account)
- && !ptr_nick_speaking);
-
- weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (
- command,
- tags,
- smart_filter ? "irc_smart_filter" : NULL,
- nick, address),
- (pos_account) ? _("%s%s%s%s has identified as %s") : _("%s%s%s%s has unidentified"),
- weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
- IRC_COLOR_MESSAGE_ACCOUNT,
- (pos_account) ? str_account : NULL);
- }
+ case IRC_CHANNEL_TYPE_PRIVATE:
+ if (!ignored
+ && weechat_config_boolean (irc_config_look_display_account_message)
+ && (irc_server_strcasecmp (server,
+ ptr_channel->name, nick) == 0))
+ {
+ weechat_printf_date_tags (
+ irc_msgbuffer_get_target_buffer (
+ server, NULL, command, NULL, ptr_channel->buffer),
+ date,
+ irc_protocol_tags (
+ command,
+ tags,
+ NULL,
+ nick, address),
+ (pos_account) ? _("%s%s%s%s has identified as %s") : _("%s%s%s%s has unidentified"),
+ weechat_prefix ("network"),
+ irc_nick_color_for_msg (server, 1, ptr_nick, nick),
+ nick,
+ IRC_COLOR_MESSAGE_ACCOUNT,
+ (pos_account) ? str_account : NULL);
+ }
+ break;
+ case IRC_CHANNEL_TYPE_CHANNEL:
+ ptr_nick = irc_nick_search (server, ptr_channel, nick);
+ if (ptr_nick)
+ {
+ if (!ignored
+ && weechat_config_boolean (irc_config_look_display_account_message))
+ {
+ ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter))
+ && (weechat_config_boolean (irc_config_look_smart_filter_account))) ?
+ irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL;
+ smart_filter = (!local_account
+ && weechat_config_boolean (irc_config_look_smart_filter)
+ && weechat_config_boolean (irc_config_look_smart_filter_account)
+ && !ptr_nick_speaking);
- if (ptr_nick->account)
- free (ptr_nick->account);
- ptr_nick->account = (cap_account_notify && pos_account) ?
- strdup (pos_account) : NULL;
+ weechat_printf_date_tags (
+ irc_msgbuffer_get_target_buffer (
+ server, NULL, command, NULL, ptr_channel->buffer),
+ date,
+ irc_protocol_tags (
+ command,
+ tags,
+ (smart_filter) ? "irc_smart_filter" : NULL,
+ nick, address),
+ (pos_account) ? _("%s%s%s%s has identified as %s") : _("%s%s%s%s has unidentified"),
+ weechat_prefix ("network"),
+ irc_nick_color_for_msg (server, 1, ptr_nick, nick),
+ nick,
+ IRC_COLOR_MESSAGE_ACCOUNT,
+ (pos_account) ? str_account : NULL);
+ }
+ if (ptr_nick->account)
+ free (ptr_nick->account);
+ ptr_nick->account = (cap_account_notify && pos_account) ?
+ strdup (pos_account) : NULL;
+ }
+ break;
}
}
@@ -1272,7 +1299,7 @@ IRC_PROTOCOL_CALLBACK(chghost)
irc_protocol_tags (
command,
tags,
- smart_filter ? "irc_smart_filter" : NULL,
+ (smart_filter) ? "irc_smart_filter" : NULL,
nick, address),
_("%s%s%s%s (%s%s%s)%s has changed host to %s%s"),
weechat_prefix ("network"),
@@ -1616,7 +1643,7 @@ IRC_PROTOCOL_CALLBACK(join)
date,
irc_protocol_tags (command,
tags,
- smart_filter ? "irc_smart_filter" : NULL,
+ (smart_filter) ? "irc_smart_filter" : NULL,
nick, address),
_("%s%s%s%s%s%s%s%s%s%s%s%s has joined %s%s%s"),
weechat_prefix ("join"),
@@ -3129,7 +3156,7 @@ IRC_PROTOCOL_CALLBACK(setname)
irc_protocol_tags (
command,
tags,
- smart_filter ? "irc_smart_filter" : NULL,
+ (smart_filter) ? "irc_smart_filter" : NULL,
NULL,
NULL),
_("%s%s%s%s has changed real name to %s\"%s%s%s\"%s"),
diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp
index 55098a96f..5e48bf5d8 100644
--- a/tests/unit/plugins/irc/test-irc-protocol.cpp
+++ b/tests/unit/plugins/irc/test-irc-protocol.cpp
@@ -662,32 +662,38 @@ TEST(IrcProtocolWithServer, account_without_account_notify_cap)
{
struct t_irc_nick *ptr_nick;
- SRV_INIT_JOIN;
+ SRV_INIT_JOIN2;
- ptr_nick = ptr_server->channels->nicks;
+ RECV(":bob!user@host PRIVMSG alice :hi Alice!");
+
+ ptr_nick = ptr_server->channels->last_nick;
POINTERS_EQUAL(NULL, ptr_nick->account);
/* not enough parameters */
- RECV(":alice!user@host ACCOUNT");
+ RECV(":bob!user@host ACCOUNT");
CHECK_ERROR_PARAMS("account", 0, 1);
POINTERS_EQUAL(NULL, ptr_nick->account);
- RECV(":alice!user@host ACCOUNT *");
- CHECK_CHAN("-- alice has unidentified");
+ RECV(":bob!user@host ACCOUNT *");
+ CHECK_CHAN("-- bob has unidentified");
+ CHECK_PV("bob", "-- bob has unidentified");
POINTERS_EQUAL(NULL, ptr_nick->account);
- RECV(":alice!user@host ACCOUNT :*");
- CHECK_CHAN("-- alice has unidentified");
+ RECV(":bob!user@host ACCOUNT :*");
+ CHECK_CHAN("-- bob has unidentified");
+ CHECK_PV("bob", "-- bob has unidentified");
POINTERS_EQUAL(NULL, ptr_nick->account);
- RECV(":alice!user@host ACCOUNT new_account");
- CHECK_CHAN("-- alice has identified as new_account");
+ RECV(":bob!user@host ACCOUNT new_account");
+ CHECK_CHAN("-- bob has identified as new_account");
+ CHECK_PV("bob", "-- bob has identified as new_account");
POINTERS_EQUAL(NULL, ptr_nick->account);
- RECV(":alice!user@host ACCOUNT :new_account");
- CHECK_CHAN("-- alice has identified as new_account");
+ RECV(":bob!user@host ACCOUNT :new_account");
+ CHECK_CHAN("-- bob has identified as new_account");
+ CHECK_PV("bob", "-- bob has identified as new_account");
POINTERS_EQUAL(NULL, ptr_nick->account);
}