summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules.h22
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/m_testnet.cpp2
-rw-r--r--src/modules/m_timedbans.cpp46
4 files changed, 35 insertions, 37 deletions
diff --git a/include/modules.h b/include/modules.h
index d47e3a62e..e09245de9 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -333,8 +333,8 @@ enum Implementation
I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite,
I_OnRawMode, I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckChannelBan, I_OnExtBanCheck,
I_OnStats, I_OnChangeLocalUserHost, I_OnPreTopicChange,
- I_OnPostTopicChange, I_OnEvent, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan,
- I_OnDelBan, I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete,
+ I_OnPostTopicChange, I_OnEvent, I_OnGlobalOper, I_OnPostConnect,
+ I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete,
I_OnPostOper, I_OnSyncNetwork, I_OnSetAway, I_OnPostCommand, I_OnPostJoin,
I_OnWhoisLine, I_OnBuildNeighborList, I_OnGarbageCollect, I_OnSetConnectClass,
I_OnText, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookIO,
@@ -1152,24 +1152,6 @@ class CoreExport Module : public classbase, public usecountbase
*/
virtual void OnPostConnect(User* user);
- /** Called whenever a ban is added to a channel's list.
- * Return a non-zero value to 'eat' the mode change and prevent the ban from being added.
- * @param source The user adding the ban
- * @param channel The channel the ban is being added to
- * @param banmask The ban mask being added
- * @return 1 to block the ban, 0 to continue as normal
- */
- virtual ModResult OnAddBan(User* source, Channel* channel,const std::string &banmask);
-
- /** Called whenever a ban is removed from a channel's list.
- * Return a non-zero value to 'eat' the mode change and prevent the ban from being removed.
- * @param source The user deleting the ban
- * @param channel The channel the ban is being deleted from
- * @param banmask The ban mask being deleted
- * @return 1 to block the unban, 0 to continue as normal
- */
- virtual ModResult OnDelBan(User* source, Channel* channel,const std::string &banmask);
-
/** Called to install an I/O hook on an event handler
* @param user The socket to possibly install the I/O hook on
* @param via The port that the user connected on
diff --git a/src/modules.cpp b/src/modules.cpp
index 560fd6b2b..56f50eb29 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -135,8 +135,6 @@ void Module::OnRequest(Request&) { }
ModResult Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { return MOD_RES_PASSTHRU; }
void Module::OnGlobalOper(User*) { }
void Module::OnPostConnect(User*) { }
-ModResult Module::OnAddBan(User*, Channel*, const std::string &) { return MOD_RES_PASSTHRU; }
-ModResult Module::OnDelBan(User*, Channel*, const std::string &) { return MOD_RES_PASSTHRU; }
void Module::OnStreamSocketAccept(StreamSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { }
int Module::OnStreamSocketWrite(StreamSocket*, std::string&) { return -1; }
void Module::OnStreamSocketClose(StreamSocket*) { }
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)