From 0243179509eb8a561b62c7845dc1322fcd94654a Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 13 Apr 2015 15:42:06 +0200 Subject: m_timedbans On channel destruction remove all timed bans belonging to the channel from internal bookkeeping --- src/modules/m_timedbans.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index f633bc3e2..ef1ae4c48 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -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); -- cgit v1.2.3