]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_timedbans On channel destruction remove all timed bans belonging to the channel...
authorAttila Molnar <attilamolnar@hush.com>
Mon, 13 Apr 2015 13:42:06 +0000 (15:42 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Mon, 13 Apr 2015 13:42:06 +0000 (15:42 +0200)
src/modules/m_timedbans.cpp

index f633bc3e209d6ea5b19ffea5bdd61411814d1018..ef1ae4c48abe9601868664e05b9cc8c89b33113a 100644 (file)
@@ -116,6 +116,22 @@ found:
        }
 };
 
+class ChannelMatcher
+{
+       Channel* const chan;
+
+ public:
+       ChannelMatcher(Channel* ch)
+               : chan(ch)
+       {
+       }
+
+       bool operator()(const TimedBan& tb) const
+       {
+               return (tb.chan == chan);
+       }
+};
+
 class ModuleTimedBans : public Module
 {
        CommandTban cmd;
@@ -128,7 +144,7 @@ class ModuleTimedBans : public Module
        void init()
        {
                ServerInstance->Modules->AddService(cmd);
-               Implementation eventlist[] = { I_OnDelBan, I_OnBackgroundTimer };
+               Implementation eventlist[] = { I_OnDelBan, I_OnBackgroundTimer, I_OnChannelDelete };
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
@@ -185,6 +201,12 @@ class ModuleTimedBans : public Module
                }
        }
 
+       void OnChannelDelete(Channel* chan)
+       {
+               // Remove all timed bans affecting the channel from internal bookkeeping
+               TimedBanList.erase(std::remove_if(TimedBanList.begin(), TimedBanList.end(), ChannelMatcher(chan)), TimedBanList.end());
+       }
+
        virtual Version GetVersion()
        {
                return Version("Adds timed bans", VF_COMMON | VF_VENDOR);