]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nonicks.cpp
Some more text fixes and improvements (#1618).
[user/henk/code/inspircd.git] / src / modules / m_nonicks.cpp
index 3ae54f2ebc64c23c33df6a4ef2d323bbc30eeb26..a796495a81d95a0b6e72fb883a85a8efe996251c 100644 (file)
 
 
 #include "inspircd.h"
-
-class NoNicks : public SimpleChannelModeHandler
-{
- public:
-       NoNicks(Module* Creator) : SimpleChannelModeHandler(Creator, "nonick", 'N') { }
-};
+#include "modules/exemption.h"
 
 class ModuleNoNickChange : public Module
 {
-       NoNicks nn;
-       bool override;
+       CheckExemption::EventProvider exemptionprov;
+       SimpleChannelModeHandler nn;
  public:
-       ModuleNoNickChange() : nn(this)
+       ModuleNoNickChange()
+               : exemptionprov(this)
+               , nn(this, "nonick", 'N')
        {
        }
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides support for channel mode +N & extban +b N: which prevents nick changes on channel", VF_VENDOR);
+               return Version("Provides channel mode +N and extban 'N' which prevents nick changes on the channel", VF_VENDOR);
        }
 
        void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
@@ -46,38 +43,30 @@ class ModuleNoNickChange : public Module
                tokens["EXTBAN"].push_back('N');
        }
 
-       ModResult OnUserPreNick(User* user, const std::string &newnick) CXX11_OVERRIDE
+       ModResult OnUserPreNick(LocalUser* user, const std::string& newnick) CXX11_OVERRIDE
        {
-               if (!IS_LOCAL(user))
-                       return MOD_RES_PASSTHRU;
-
-               for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
+               for (User::ChanList::iterator i = user->chans.begin(); i != user->chans.end(); i++)
                {
-                       Channel* curr = *i;
+                       Channel* curr = (*i)->chan;
 
-                       ModResult res = ServerInstance->OnCheckExemption(user,curr,"nonick");
+                       ModResult res = CheckExemption::Call(exemptionprov, user, curr, "nonick");
 
                        if (res == MOD_RES_ALLOW)
                                continue;
 
-                       if (override && user->IsOper())
+                       if (user->HasPrivPermission("channels/ignore-nonicks"))
                                continue;
 
                        if (!curr->GetExtBanStatus(user, 'N').check(!curr->IsModeSet(nn)))
                        {
-                               user->WriteNumeric(ERR_CANTCHANGENICK, "%s :Can't change nickname while on %s (+N is set)",
-                                       user->nick.c_str(), curr->name.c_str());
+                               user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("Cannot change nickname while on %s (+N is set)",
+                                       curr->name.c_str()));
                                return MOD_RES_DENY;
                        }
                }
 
                return MOD_RES_PASSTHRU;
        }
-
-       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
-       {
-               override = ServerInstance->Config->ConfValue("nonicks")->getBool("operoverride", false);
-       }
 };
 
 MODULE_INIT(ModuleNoNickChange)