]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nonicks.cpp
Fix infinite loop on alias expansion, found by Adam
[user/henk/code/inspircd.git] / src / modules / m_nonicks.cpp
index 31839c13aec84ed8b3b934c089ae720e43616167..368eaa34354d736dd4edc64a90189d5b00405352 100644 (file)
@@ -18,7 +18,7 @@
 class NoNicks : public ModeHandler
 {
  public:
-       NoNicks(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'N', 0, 0, false, MODETYPE_CHANNEL, false) { }
+       NoNicks(Module* Creator) : ModeHandler(Creator, "nonick", 'N', PARAM_NONE, MODETYPE_CHANNEL) { }
 
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
@@ -47,7 +47,7 @@ class ModuleNoNickChange : public Module
 {
        NoNicks nn;
  public:
-       ModuleNoNickChange(InspIRCd* Me) : Module(Me), nn(Me, this)
+       ModuleNoNickChange() : nn(this)
        {
                ServerInstance->Modes->AddMode(&nn);
                Implementation eventlist[] = { I_OnUserPreNick, I_On005Numeric };
@@ -56,12 +56,11 @@ class ModuleNoNickChange : public Module
 
        virtual ~ModuleNoNickChange()
        {
-               ServerInstance->Modes->DelMode(&nn);
        }
 
        virtual Version GetVersion()
        {
-               return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version("Provides support for channel mode +N & extban +b N: which prevents nick changes on channel", VF_COMMON | VF_VENDOR);
        }
 
 
@@ -79,14 +78,17 @@ class ModuleNoNickChange : public Module
                        return MOD_RES_PASSTHRU;
 
                // Allow forced nick changes.
-               if (User::NICKForced.get(user))
+               if (ServerInstance->NICKForced.get(user))
                        return MOD_RES_PASSTHRU;
 
                for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
                {
                        Channel* curr = *i;
 
-                       if (CHANOPS_EXEMPT(ServerInstance, 'N') && curr->GetPrefixValue(user) == OP_VALUE)
+                       ModResult res;
+                       FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (user,curr,"nonick"));
+
+                       if (res == MOD_RES_ALLOW)
                                continue;
 
                        if (!curr->GetExtBanStatus(user, 'N').check(!curr->IsModeSet('N')))