summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/users.h3
-rw-r--r--src/users.cpp18
2 files changed, 13 insertions, 8 deletions
diff --git a/include/users.h b/include/users.h
index b33cf2916..d8860e6f2 100644
--- a/include/users.h
+++ b/include/users.h
@@ -369,6 +369,9 @@ public:
*/
bool BadPassword();
+ /** Determines whether this user should receive a PRIVMSG instead of a NOTICE. */
+ bool ShouldPrivmsg() const;
+
/** Finds a user by nick, or possibly UID
* @param name The nick, or possibly UID, to lookup
* @param nick_only set to true to only look up by nick, not UID
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)