]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_services_account.cpp
Convert a bunch of time-related config options to getDuration.
[user/henk/code/inspircd.git] / src / modules / m_services_account.cpp
index 48ab511f08c8a557cccbd1af4892ea425c488e26..1ff206ed1427ad4f62c93ead86d1d2d54b04cd10 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "inspircd.h"
 #include "modules/account.h"
+#include "modules/exemption.h"
 
 /** Channel mode +r - mark a channel as identified
  */
@@ -46,7 +47,7 @@ class Channel_r : public ModeHandler
                }
                else
                {
-                       source->WriteNumeric(500, ":Only a server may modify the +r channel mode");
+                       source->WriteNumeric(500, "Only a server may modify the +r channel mode");
                }
                return MODEACTION_DENY;
        }
@@ -72,7 +73,7 @@ class User_r : public ModeHandler
                }
                else
                {
-                       source->WriteNumeric(500, ":Only a server may modify the +r user mode");
+                       source->WriteNumeric(500, "Only a server may modify the +r user mode");
                }
                return MODEACTION_DENY;
        }
@@ -128,8 +129,7 @@ class AccountExtItemImpl : public AccountExtItem
                        // Logged in
                        if (IS_LOCAL(user))
                        {
-                               user->WriteNumeric(900, "%s %s :You are now logged in as %s",
-                                       user->GetFullHost().c_str(), value.c_str(), value.c_str());
+                               user->WriteNumeric(900, user->GetFullHost(), value, InspIRCd::Format("You are now logged in as %s", value.c_str()));
                        }
                }
                // If value is empty then logged out
@@ -140,6 +140,7 @@ class AccountExtItemImpl : public AccountExtItem
 
 class ModuleServicesAccount : public Module, public Whois::EventListener
 {
+       CheckExemption::EventProvider exemptionprov;
        AChannel_R m1;
        AChannel_M m2;
        AUser_R m3;
@@ -150,6 +151,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
  public:
        ModuleServicesAccount()
                : Whois::EventListener(this)
+               , exemptionprov(this)
                , m1(this), m2(this), m3(this), m4(this), m5(this)
                , accountname(this)
                , checking_ban(false)
@@ -169,20 +171,20 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
 
                if (account)
                {
-                       whois.SendLine(330, "%s :is logged in as", account->c_str());
+                       whois.SendLine(330, *account, "is logged in as");
                }
 
                if (whois.GetTarget()->IsModeSet(m5))
                {
                        /* user is registered */
-                       whois.SendLine(307, ":is a registered nick");
+                       whois.SendLine(307, "is a registered nick");
                }
        }
 
        void OnUserPostNick(User* user, const std::string &oldnick) CXX11_OVERRIDE
        {
                /* On nickchange, if they have +r, remove it */
-               if (user->IsModeSet(m5) && assign(user->nick) != oldnick)
+               if ((user->IsModeSet(m5)) && (ServerInstance->FindNickOnly(oldnick) != user))
                        m5.RemoveMode(user);
        }
 
@@ -197,12 +199,13 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
                if (target_type == TYPE_CHANNEL)
                {
                        Channel* c = (Channel*)dest;
-                       ModResult res = ServerInstance->OnCheckExemption(user,c,"regmoderated");
+                       ModResult res;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "regmoderated"));
 
                        if (c->IsModeSet(m2) && !is_registered && res != MOD_RES_ALLOW)
                        {
                                // user messaging a +M channel and is not registered
-                               user->WriteNumeric(477, c->name+" :You need to be identified to a registered account to message this channel");
+                               user->WriteNumeric(477, c->name, "You need to be identified to a registered account to message this channel");
                                return MOD_RES_DENY;
                        }
                }
@@ -213,7 +216,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
                        if (u->IsModeSet(m3) && !is_registered)
                        {
                                // user messaging a +R user and is not registered
-                               user->WriteNumeric(477, u->nick +" :You need to be identified to a registered account to message this user");
+                               user->WriteNumeric(477, u->nick, "You need to be identified to a registered account to message this user");
                                return MOD_RES_DENY;
                        }
                }
@@ -268,7 +271,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
                                if (!is_registered)
                                {
                                        // joining a +R channel and not identified
-                                       user->WriteNumeric(477, chan->name + " :You need to be identified to a registered account to join this channel");
+                                       user->WriteNumeric(477, chan->name, "You need to be identified to a registered account to join this channel");
                                        return MOD_RES_DENY;
                                }
                        }