summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-02-26 14:41:50 +0000
committerSadie Powell <sadie@witchery.services>2024-02-26 14:41:50 +0000
commit83dd96b9f2ea3a10c9c55ecec42d4f7e330643fe (patch)
tree1823102f16cd149081013004bb734af90adaaced /src
parentcabaa079dfb1e5a65b770914676dd4b2f0f16b10 (diff)
Extract should privmsg logic to its own function.
Diffstat (limited to 'src')
-rw-r--r--src/users.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 956d77b9c..efe71f2a9 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -338,17 +338,10 @@ namespace
{
const char *translated_message = Language::Translate(target, msg.c_str());
- /* Send privmsg instead of notice if:
- * - UsePrivmsg is enabled
- * - The user is not registered and NSDefMsg is enabled
- * - The user is registered and has set /ns set msg on
- */
- auto account = target->Account();
- bool send_privmsg = Config->UsePrivmsg && ((!account && Config->DefPrivmsg) || (account && account->HasExt("MSG")));
sepstream sep(translated_message, '\n', true);
for (Anope::string tok; sep.GetToken(tok);)
{
- if (send_privmsg)
+ if (target->ShouldPrivmsg())
IRCD->SendPrivmsgInternal(source, target->GetUID(), tok, tags);
else
IRCD->SendNoticeInternal(source, target->GetUID(), tok, tags);
@@ -859,6 +852,15 @@ bool User::BadPassword()
return false;
}
+bool User::ShouldPrivmsg() const
+{
+ // Send a PRIVMSG instead of a NOTICE if:
+ // 1. options:useprivmsg is enabled.
+ // 2. The user is not registered and msg is in nickserv:defaults.
+ // 3. The user is registered and has set /ns set message on.
+ return Config->UsePrivmsg && ((!nc && Config->DefPrivmsg) || (nc && nc->HasExt("MSG")));
+}
+
User* User::Find(const Anope::string &name, bool nick_only)
{
if (!nick_only && IRCD && IRCD->RequiresID)