]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_blockcolor.cpp
Move OnSync{Channel,Network,User} to ServerEventListener.
[user/henk/code/inspircd.git] / src / modules / m_blockcolor.cpp
index 2c7207698cbaab65c0d8f80bc54c15bb0fc7f30a..e3135185d2e63b55ec73599ff0f073c6b97c1433 100644 (file)
 
 
 #include "inspircd.h"
-
-/* $ModDesc: Provides channel mode +c to block color */
-
-/** Handles the +c channel mode
- */
-class BlockColor : public SimpleChannelModeHandler
-{
- public:
-       BlockColor(Module* Creator) : SimpleChannelModeHandler(Creator, "blockcolor", 'c') { }
-};
+#include "modules/exemption.h"
 
 class ModuleBlockColor : public Module
 {
-       BlockColor bc;
+       CheckExemption::EventProvider exemptionprov;
+       SimpleChannelModeHandler bc;
  public:
 
-       ModuleBlockColor() : bc(this)
-       {
-       }
-
-       void init() CXX11_OVERRIDE
+       ModuleBlockColor()
+               : exemptionprov(this)
+               , bc(this, "blockcolor", 'c')
        {
-               ServerInstance->Modules->AddService(bc);
-               Implementation eventlist[] = { I_OnUserPreMessage, I_On005Numeric };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
@@ -59,12 +46,12 @@ class ModuleBlockColor : public Module
                if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
                {
                        Channel* c = (Channel*)dest;
-                       ModResult res = ServerInstance->OnCheckExemption(user,c,"blockcolor");
+                       ModResult res = CheckExemption::Call(exemptionprov, user, c, "blockcolor");
 
                        if (res == MOD_RES_ALLOW)
                                return MOD_RES_PASSTHRU;
 
-                       if (!c->GetExtBanStatus(user, 'c').check(!c->IsModeSet('c')))
+                       if (!c->GetExtBanStatus(user, 'c').check(!c->IsModeSet(bc)))
                        {
                                for (std::string::iterator i = text.begin(); i != text.end(); i++)
                                {
@@ -76,7 +63,7 @@ class ModuleBlockColor : public Module
                                                case 21:
                                                case 22:
                                                case 31:
-                                                       user->WriteNumeric(404, "%s %s :Can't send colors to channel (+c set)",user->nick.c_str(), c->name.c_str());
+                                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send colors to channel (+c set)");
                                                        return MOD_RES_DENY;
                                                break;
                                        }