From 9fc218c005543384bcad73747a0574c8c6ab6289 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Mon, 8 Apr 2013 21:55:53 +0200 Subject: Remove OnAddBan and OnDelBan hooks --- src/modules/m_testnet.cpp | 2 -- src/modules/m_timedbans.cpp | 46 ++++++++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 15 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_testnet.cpp b/src/modules/m_testnet.cpp index 843ecd4b7..01d0406b0 100644 --- a/src/modules/m_testnet.cpp +++ b/src/modules/m_testnet.cpp @@ -152,8 +152,6 @@ static void checkall(Module* noimpl) CHK(OnEvent); CHK(OnGlobalOper); CHK(OnPostConnect); - CHK(OnAddBan); - CHK(OnDelBan); CHK(OnChangeLocalUserGECOS); CHK(OnUserRegister); CHK(OnChannelPreDelete); diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index e10a622e9..81b12d881 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -114,27 +114,22 @@ found: } }; -class ModuleTimedBans : public Module +class BanWatcher : public ModeWatcher { - CommandTban cmd; public: - ModuleTimedBans() - : cmd(this) + BanWatcher(Module* parent) + : ModeWatcher(parent, 'b', MODETYPE_CHANNEL) { } - void init() + void AfterMode(User* source, User* dest, Channel* chan, const std::string& banmask, bool adding, ModeType type) { - ServerInstance->Modules->AddService(cmd); - Implementation eventlist[] = { I_OnDelBan, I_OnBackgroundTimer }; - ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); - } + if (adding) + return; - virtual ModResult OnDelBan(User* source, Channel* chan, const std::string &banmask) - { irc::string listitem = banmask.c_str(); irc::string thischan = chan->name.c_str(); - for (timedbans::iterator i = TimedBanList.begin(); i != TimedBanList.end(); i++) + for (timedbans::iterator i = TimedBanList.begin(); i != TimedBanList.end(); ++i) { irc::string target = i->mask.c_str(); irc::string tchan = i->channel.c_str(); @@ -144,7 +139,32 @@ class ModuleTimedBans : public Module break; } } - return MOD_RES_PASSTHRU; + } +}; + +class ModuleTimedBans : public Module +{ + CommandTban cmd; + BanWatcher banwatcher; + + public: + ModuleTimedBans() + : cmd(this) + , banwatcher(this) + { + } + + void init() + { + ServerInstance->Modules->AddService(cmd); + Implementation eventlist[] = { I_OnBackgroundTimer }; + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); + ServerInstance->Modes->AddModeWatcher(&banwatcher); + } + + ~ModuleTimedBans() + { + ServerInstance->Modes->DelModeWatcher(&banwatcher); } virtual void OnBackgroundTimer(time_t curtime) -- cgit v1.2.3