diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-04-13 15:42:06 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-04-13 15:42:06 +0200 |
commit | 0243179509eb8a561b62c7845dc1322fcd94654a (patch) | |
tree | d6b08d1f9f7f730899e63988c713c35051d04db4 /src/modules/m_timedbans.cpp | |
parent | 8723866b4cdf100892677ab5c1619fcee9536d9b (diff) |
m_timedbans On channel destruction remove all timed bans belonging to the channel from internal bookkeeping
Diffstat (limited to 'src/modules/m_timedbans.cpp')
-rw-r--r-- | src/modules/m_timedbans.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
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); |