]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_override.cpp
m_dccallow Add config option to control max entries on a list
[user/henk/code/inspircd.git] / src / modules / m_override.cpp
index c7a6b8bfd6df2b44c332f8d2b7508b3fb780324d..3e42c4f7927885f023bc9b5bf05775b21f8a28a8 100644 (file)
@@ -33,15 +33,29 @@ class ModuleOverride : public Module
        bool RequireKey;
        bool NoisyOverride;
 
+       static bool IsOverride(unsigned int userlevel, const std::string& modeline)
+       {
+               for (std::string::const_iterator i = modeline.begin(); i != modeline.end(); ++i)
+               {
+                       ModeHandler* mh = ServerInstance->Modes->FindMode(*i, MODETYPE_CHANNEL);
+                       if (!mh)
+                               continue;
+
+                       if (mh->GetLevelRequired() > userlevel)
+                               return true;
+               }
+               return false;
+       }
+
  public:
 
-       ModuleOverride()
-                       {
+       void init()
+       {
                // read our config options (main config file)
                OnRehash(NULL);
                ServerInstance->SNO->EnableSnomask('v', "OVERRIDE");
                Implementation eventlist[] = { I_OnRehash, I_OnPreMode, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPreTopicChange };
-               ServerInstance->Modules->Attach(eventlist, this, 6);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        void OnRehash(User* user)
@@ -105,7 +119,10 @@ class ModuleOverride : public Module
 
                unsigned int mode = channel->GetPrefixValue(source);
 
-               if (mode < HALFOP_VALUE && CanOverride(source, "MODE"))
+               if (!IsOverride(mode, parameters[1]))
+                       return MOD_RES_PASSTHRU;
+
+               if (CanOverride(source, "MODE"))
                {
                        std::string msg = source->nick+" overriding modes:";
                        for(unsigned int i=0; i < parameters.size(); i++)