summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-04-08 21:55:53 +0200
committerattilamolnar <attilamolnar@hush.com>2013-04-08 21:55:53 +0200
commit9fc218c005543384bcad73747a0574c8c6ab6289 (patch)
tree8485c8f29f01c44cc920daa2d502b80fc697474d /src/modules
parent745378a3290fe70dc38e7bd98ec34b740a0410a7 (diff)
Remove OnAddBan and OnDelBan hooks
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_testnet.cpp2
-rw-r--r--src/modules/m_timedbans.cpp46
2 files changed, 33 insertions, 15 deletions
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)