]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nokicks.cpp
Merge insp20
[user/henk/code/inspircd.git] / src / modules / m_nokicks.cpp
index 58e6fbea134564e5a6234568dae8dc365ab14885..fb3455567b53621ca12b1e7809e384601c980775 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides channel mode +Q to prevent kicks on the channel. */
-
 class NoKicks : public SimpleChannelModeHandler
 {
  public:
@@ -38,45 +36,28 @@ class ModuleNoKicks : public Module
        ModuleNoKicks()
                : nk(this)
        {
-               if (!ServerInstance->Modes->AddMode(&nk))
-                       throw ModuleException("Could not add new modes!");
-               Implementation eventlist[] = { I_OnUserPreKick, I_On005Numeric };
-               ServerInstance->Modules->Attach(eventlist, this, 2);
        }
 
-       void On005Numeric(std::string &output)
+       void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
        {
-               ServerInstance->AddExtBanChar('Q');
+               tokens["EXTBAN"].push_back('Q');
        }
 
-       ModResult OnUserPreKick(User* source, Membership* memb, const std::string &reason)
+       ModResult OnUserPreKick(User* source, Membership* memb, const std::string &reason) CXX11_OVERRIDE
        {
-               if (!memb->chan->GetExtBanStatus(source, 'Q').check(!memb->chan->IsModeSet('Q')))
+               if (!memb->chan->GetExtBanStatus(source, 'Q').check(!memb->chan->IsModeSet(nk)))
                {
-                       if ((ServerInstance->ULine(source->nick.c_str())) || ServerInstance->ULine(source->server))
-                       {
-                               // ulines can still kick with +Q in place
-                               return MOD_RES_PASSTHRU;
-                       }
-                       else
-                       {
-                               // nobody else can (not even opers with override, and founders)
-                               source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Can't kick user %s from channel (+Q set)",source->nick.c_str(), memb->chan->name.c_str(), memb->user->nick.c_str());
-                               return MOD_RES_DENY;
-                       }
+                       // Can't kick with Q in place, not even opers with override, and founders
+                       source->WriteNumeric(ERR_CHANOPRIVSNEEDED, memb->chan->name, InspIRCd::Format("Can't kick user %s from channel (+Q set)", memb->user->nick.c_str()));
+                       return MOD_RES_DENY;
                }
                return MOD_RES_PASSTHRU;
        }
 
-       ~ModuleNoKicks()
-       {
-       }
-
-       Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Provides channel mode +Q to prevent kicks on the channel.", VF_VENDOR);
        }
 };
 
-
 MODULE_INIT(ModuleNoKicks)