]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_censor.cpp
Add <options:exemptchanops> support to m_censor and m_blockcaps, and tidy up the...
[user/henk/code/inspircd.git] / src / modules / m_censor.cpp
index 03c5bfb69e2ff5685c14d7acdf5b26ce8ef60eff..4eaf1e3b47406a4f982cd1ce9b44779c58e8cf5a 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -27,7 +27,7 @@ class CensorUser : public ModeHandler
  public:
        CensorUser(InspIRCd* Instance) : ModeHandler(Instance, 'G', 0, 0, false, MODETYPE_USER, false) { }
 
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
        {
                if (adding)
                {
@@ -57,7 +57,7 @@ class CensorChannel : public ModeHandler
  public:
        CensorChannel(InspIRCd* Instance) : ModeHandler(Instance, 'G', 0, 0, false, MODETYPE_CHANNEL, false) { }
 
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
        {
                if (adding)
                {
@@ -76,7 +76,7 @@ class CensorChannel : public ModeHandler
                        }
                }
 
-               return MODEACTION_ALLOW;
+               return MODEACTION_DENY;
        }
 };
 
@@ -97,14 +97,16 @@ class ModuleCensor : public Module
                OnRehash(NULL,"");
                cu = new CensorUser(ServerInstance);
                cc = new CensorChannel(ServerInstance);
-               if (!ServerInstance->AddMode(cu) || !ServerInstance->AddMode(cc))
+               if (!ServerInstance->Modes->AddMode(cu) || !ServerInstance->Modes->AddMode(cc))
+               {
+                       delete cu;
+                       delete cc;
                        throw ModuleException("Could not add new modes!");
+               }
+               Implementation eventlist[] = { I_OnRehash, I_OnUserPreMessage, I_OnUserPreNotice };
+               ServerInstance->Modules->Attach(eventlist, this, 3);
        }
 
-       void Implements(char* List)
-       {
-               List[I_OnRehash] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
-       }
 
        virtual ~ModuleCensor()
        {
@@ -138,7 +140,14 @@ class ModuleCensor : public Module
                if (target_type == TYPE_USER)
                        active = ((User*)dest)->IsModeSet('G');
                else if (target_type == TYPE_CHANNEL)
+               {
                        active = ((Channel*)dest)->IsModeSet('G');
+                       Channel* c = (Channel*)dest;
+                       if (CHANOPS_EXEMPT(ServerInstance, 'G') && c->GetStatus(user) == STATUS_OP)
+                       {
+                               return 0;
+                       }
+               }
 
                if (!active)
                        return 0;