]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_stripcolor.cpp
Add support for hashed WebIRC passwords to m_cgiirc.
[user/henk/code/inspircd.git] / src / modules / m_stripcolor.cpp
index b50c22297255a40bca75e93c42951f0ae8d82cda..6ad32bfc1010207530b46b36c976b3fa857f50ce 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 /** Handles channel mode +S
  */
@@ -40,20 +41,18 @@ class UserStripColor : public SimpleUserModeHandler
 
 class ModuleStripColor : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        ChannelStripColor csc;
        UserStripColor usc;
 
  public:
-       ModuleStripColor() : csc(this), usc(this)
+       ModuleStripColor()
+               : exemptionprov(this)
+               , csc(this)
+               , usc(this)
        {
        }
 
-       void init() CXX11_OVERRIDE
-       {
-               ServerInstance->Modules->AddService(usc);
-               ServerInstance->Modules->AddService(csc);
-       }
-
        void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
        {
                tokens["EXTBAN"].push_back('S');
@@ -73,7 +72,8 @@ class ModuleStripColor : public Module
                else if (target_type == TYPE_CHANNEL)
                {
                        Channel* t = (Channel*)dest;
-                       ModResult res = ServerInstance->OnCheckExemption(user,t,"stripcolor");
+                       ModResult res;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, t, "stripcolor"));
 
                        if (res == MOD_RES_ALLOW)
                                return MOD_RES_PASSTHRU;
@@ -89,6 +89,24 @@ class ModuleStripColor : public Module
                return MOD_RES_PASSTHRU;
        }
 
+       void OnUserPart(Membership* memb, std::string& partmessage, CUList& except_list) CXX11_OVERRIDE
+       {
+               User* user = memb->user;
+               Channel* channel = memb->chan;
+
+               if (!IS_LOCAL(user))
+                       return;
+
+               if (channel->GetExtBanStatus(user, 'S').check(!user->IsModeSet(csc)))
+               {
+                       ModResult res;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, channel, "stripcolor"));
+
+                       if (res != MOD_RES_ALLOW)
+                               InspIRCd::StripColor(partmessage);
+               }
+       }
+
        Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Provides channel +S mode (strip ansi color)", VF_VENDOR);