diff options
author | Peter Powell <petpow@saberuk.com> | 2017-03-20 11:43:24 +0000 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2017-03-20 11:47:59 +0000 |
commit | 81027f3a0888ac4c8e3fb6ea90081492defce946 (patch) | |
tree | a8da074f8feb486af8ef4aebf67e8c901f2340f3 /src/modules | |
parent | 5583d8dc5ff202d411d7985b6bbfb240beeacddd (diff) |
Move the OnCheckExemption hook out of the core.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_auditorium.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_blockcaps.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_blockcolor.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_censor.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_chanfilter.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_exemptchanops.cpp | 23 | ||||
-rw-r--r-- | src/modules/m_messageflood.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_nickflood.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_noctcp.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_nonicks.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_nonotice.cpp | 7 | ||||
-rw-r--r-- | src/modules/m_repeat.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_services_account.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_stripcolor.cpp | 21 |
14 files changed, 108 insertions, 46 deletions
diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp index 6f9eeb252..cd257eff3 100644 --- a/src/modules/m_auditorium.cpp +++ b/src/modules/m_auditorium.cpp @@ -21,6 +21,7 @@ #include "inspircd.h" +#include "modules/exemption.h" class AuditoriumMode : public SimpleChannelModeHandler { @@ -33,13 +34,16 @@ class AuditoriumMode : public SimpleChannelModeHandler class ModuleAuditorium : public Module { + CheckExemption::EventProvider exemptionprov; AuditoriumMode aum; bool OpsVisible; bool OpsCanSee; bool OperCanSee; public: - ModuleAuditorium() : aum(this) + ModuleAuditorium() + : exemptionprov(this) + , aum(this) { } @@ -62,7 +66,8 @@ class ModuleAuditorium : public Module if (!memb->chan->IsModeSet(&aum)) return true; - ModResult res = ServerInstance->OnCheckExemption(memb->user, memb->chan, "auditorium-vis"); + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (memb->user, memb->chan, "auditorium-vis")); return res.check(OpsVisible && memb->getRank() >= OP_VALUE); } @@ -78,7 +83,8 @@ class ModuleAuditorium : public Module return true; // Can you see the list by permission? - ModResult res = ServerInstance->OnCheckExemption(issuer,memb->chan,"auditorium-see"); + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (issuer, memb->chan, "auditorium-see")); if (res.check(OpsCanSee && memb->chan->GetPrefixValue(issuer) >= OP_VALUE)) return true; diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp index cd7698d69..6e67cb309 100644 --- a/src/modules/m_blockcaps.cpp +++ b/src/modules/m_blockcaps.cpp @@ -21,6 +21,7 @@ #include "inspircd.h" +#include "modules/exemption.h" /** Handles the +B channel mode @@ -33,13 +34,16 @@ class BlockCaps : public SimpleChannelModeHandler class ModuleBlockCAPS : public Module { + CheckExemption::EventProvider exemptionprov; BlockCaps bc; unsigned int percent; unsigned int minlen; char capsmap[256]; public: - ModuleBlockCAPS() : bc(this) + ModuleBlockCAPS() + : exemptionprov(this) + , bc(this) { } @@ -56,7 +60,8 @@ public: return MOD_RES_PASSTHRU; Channel* c = (Channel*)dest; - ModResult res = ServerInstance->OnCheckExemption(user,c,"blockcaps"); + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "blockcaps")); if (res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp index 567bdb249..7c961d96a 100644 --- a/src/modules/m_blockcolor.cpp +++ b/src/modules/m_blockcolor.cpp @@ -22,6 +22,7 @@ #include "inspircd.h" +#include "modules/exemption.h" /** Handles the +c channel mode */ @@ -33,10 +34,13 @@ class BlockColor : public SimpleChannelModeHandler class ModuleBlockColor : public Module { + CheckExemption::EventProvider exemptionprov; BlockColor bc; public: - ModuleBlockColor() : bc(this) + ModuleBlockColor() + : exemptionprov(this) + , bc(this) { } @@ -50,7 +54,8 @@ class ModuleBlockColor : public Module if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user))) { Channel* c = (Channel*)dest; - ModResult res = ServerInstance->OnCheckExemption(user,c,"blockcolor"); + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "blockcolor")); if (res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index d2a60275a..56639b298 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -21,6 +21,7 @@ #include "inspircd.h" +#include "modules/exemption.h" typedef insp::flat_map<irc::string, irc::string> censor_t; @@ -42,12 +43,18 @@ class CensorChannel : public SimpleChannelModeHandler class ModuleCensor : public Module { + CheckExemption::EventProvider exemptionprov; censor_t censors; CensorUser cu; CensorChannel cc; public: - ModuleCensor() : cu(this), cc(this) { } + ModuleCensor() + : exemptionprov(this) + , cu(this) + , cc(this) + { + } // format of a config entry is <badword text="shit" replace="poo"> ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE @@ -63,7 +70,8 @@ class ModuleCensor : public Module { Channel* c = (Channel*)dest; active = c->IsModeSet(cc); - ModResult res = ServerInstance->OnCheckExemption(user,c,"censor"); + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "censor")); if (res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index a7bc21557..b642cb933 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -25,6 +25,7 @@ #include "inspircd.h" #include "listmode.h" +#include "modules/exemption.h" /** Handles channel mode +g */ @@ -62,13 +63,15 @@ class ChanFilter : public ListModeBase class ModuleChanFilter : public Module { + CheckExemption::EventProvider exemptionprov; ChanFilter cf; bool hidemask; public: ModuleChanFilter() - : cf(this) + : exemptionprov(this) + , cf(this) { } @@ -84,7 +87,8 @@ class ModuleChanFilter : public Module return MOD_RES_PASSTHRU; Channel* chan = static_cast<Channel*>(dest); - ModResult res = ServerInstance->OnCheckExemption(user,chan,"filter"); + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, chan, "filter")); if (!IS_LOCAL(user) || res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp index 2884385fb..0c67037f0 100644 --- a/src/modules/m_exemptchanops.cpp +++ b/src/modules/m_exemptchanops.cpp @@ -19,6 +19,7 @@ #include "inspircd.h" #include "listmode.h" +#include "modules/exemption.h" /** Handles channel mode +X */ @@ -68,11 +69,15 @@ class ExemptChanOps : public ListModeBase } }; -class ExemptHandler : public HandlerBase3<ModResult, User*, Channel*, const std::string&> +class ExemptHandler : public CheckExemption::EventListener { public: ExemptChanOps ec; - ExemptHandler(Module* me) : ec(me) {} + ExemptHandler(Module* me) + : CheckExemption::EventListener(me) + , ec(me) + { + } PrefixMode* FindMode(const std::string& mid) { @@ -83,7 +88,7 @@ class ExemptHandler : public HandlerBase3<ModResult, User*, Channel*, const std: return mh ? mh->IsPrefixMode() : NULL; } - ModResult Call(User* user, Channel* chan, const std::string& restriction) + ModResult OnCheckExemption(User* user, Channel* chan, const std::string& restriction) CXX11_OVERRIDE { unsigned int mypfx = chan->GetPrefixValue(user); std::string minmode; @@ -108,7 +113,7 @@ class ExemptHandler : public HandlerBase3<ModResult, User*, Channel*, const std: if (mh || minmode == "*") return MOD_RES_DENY; - return ServerInstance->HandleOnCheckExemption.Call(user, chan, restriction); + return MOD_RES_PASSTHRU; } }; @@ -121,16 +126,6 @@ class ModuleExemptChanOps : public Module { } - void init() CXX11_OVERRIDE - { - ServerInstance->OnCheckExemption = &eh; - } - - ~ModuleExemptChanOps() - { - ServerInstance->OnCheckExemption = &ServerInstance->HandleOnCheckExemption; - } - Version GetVersion() CXX11_OVERRIDE { return Version("Provides the ability to allow channel operators to be exempt from certain modes.",VF_VENDOR); diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 7323605cb..46df977a5 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -24,6 +24,7 @@ #include "inspircd.h" +#include "modules/exemption.h" /** Holds flood settings and state for mode +f */ @@ -103,12 +104,14 @@ class MsgFlood : public ParamMode<MsgFlood, SimpleExtItem<floodsettings> > class ModuleMsgFlood : public Module { + CheckExemption::EventProvider exemptionprov; MsgFlood mf; public: ModuleMsgFlood() - : mf(this) + : exemptionprov(this) + , mf(this) { } @@ -121,7 +124,9 @@ class ModuleMsgFlood : public Module if ((!IS_LOCAL(user)) || !dest->IsModeSet(mf)) return MOD_RES_PASSTHRU; - if (ServerInstance->OnCheckExemption(user,dest,"flood") == MOD_RES_ALLOW) + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, dest, "flood")); + if (res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; floodsettings *f = mf.ext.get(dest); diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index abb3cdfaf..a4a87f691 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -19,6 +19,7 @@ #include "inspircd.h" +#include "modules/exemption.h" // The number of seconds nickname changing will be blocked for. static unsigned int duration; @@ -121,11 +122,13 @@ class NickFlood : public ParamMode<NickFlood, SimpleExtItem<nickfloodsettings> > class ModuleNickFlood : public Module { + CheckExemption::EventProvider exemptionprov; NickFlood nf; public: ModuleNickFlood() - : nf(this) + : exemptionprov(this) + , nf(this) { } @@ -145,7 +148,7 @@ class ModuleNickFlood : public Module nickfloodsettings *f = nf.ext.get(channel); if (f) { - res = ServerInstance->OnCheckExemption(user,channel,"nickflood"); + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, channel, "nickflood")); if (res == MOD_RES_ALLOW) continue; @@ -184,7 +187,7 @@ class ModuleNickFlood : public Module nickfloodsettings *f = nf.ext.get(channel); if (f) { - res = ServerInstance->OnCheckExemption(user,channel,"nickflood"); + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, channel, "nickflood")); if (res == MOD_RES_ALLOW) return; diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp index 49b53ee95..9dd9bf852 100644 --- a/src/modules/m_noctcp.cpp +++ b/src/modules/m_noctcp.cpp @@ -20,6 +20,7 @@ #include "inspircd.h" +#include "modules/exemption.h" class NoCTCP : public SimpleChannelModeHandler { @@ -29,11 +30,13 @@ class NoCTCP : public SimpleChannelModeHandler class ModuleNoCTCP : public Module { + CheckExemption::EventProvider exemptionprov; NoCTCP nc; public: ModuleNoCTCP() - : nc(this) + : exemptionprov(this) + , nc(this) { } @@ -50,7 +53,8 @@ class ModuleNoCTCP : public Module if ((text.empty()) || (text[0] != '\001') || (!strncmp(text.c_str(),"\1ACTION ",8))) return MOD_RES_PASSTHRU; - ModResult res = ServerInstance->OnCheckExemption(user,c,"noctcp"); + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "noctcp")); if (res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp index d4da3e951..c6de17e89 100644 --- a/src/modules/m_nonicks.cpp +++ b/src/modules/m_nonicks.cpp @@ -20,6 +20,7 @@ #include "inspircd.h" +#include "modules/exemption.h" class NoNicks : public SimpleChannelModeHandler { @@ -29,10 +30,13 @@ class NoNicks : public SimpleChannelModeHandler class ModuleNoNickChange : public Module { + CheckExemption::EventProvider exemptionprov; NoNicks nn; bool override; public: - ModuleNoNickChange() : nn(this) + ModuleNoNickChange() + : exemptionprov(this) + , nn(this) { } @@ -52,7 +56,8 @@ class ModuleNoNickChange : public Module { Channel* curr = (*i)->chan; - ModResult res = ServerInstance->OnCheckExemption(user,curr,"nonick"); + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, curr, "nonick")); if (res == MOD_RES_ALLOW) continue; diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp index 3d6d0bb09..ec5be9517 100644 --- a/src/modules/m_nonotice.cpp +++ b/src/modules/m_nonotice.cpp @@ -20,6 +20,7 @@ #include "inspircd.h" +#include "modules/exemption.h" class NoNotice : public SimpleChannelModeHandler { @@ -29,11 +30,13 @@ class NoNotice : public SimpleChannelModeHandler class ModuleNoNotice : public Module { + CheckExemption::EventProvider exemptionprov; NoNotice nt; public: ModuleNoNotice() - : nt(this) + : exemptionprov(this) + , nt(this) { } @@ -50,7 +53,7 @@ class ModuleNoNotice : public Module Channel* c = (Channel*)dest; if (!c->GetExtBanStatus(user, 'T').check(!c->IsModeSet(nt))) { - res = ServerInstance->OnCheckExemption(user,c,"nonotice"); + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "nonotice")); if (res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; else diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index 21bca0f3f..9715fcf6f 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -18,6 +18,7 @@ #include "inspircd.h" +#include "modules/exemption.h" class ChannelSettings { @@ -339,10 +340,15 @@ class RepeatMode : public ParamMode<RepeatMode, SimpleExtItem<ChannelSettings> > class RepeatModule : public Module { + CheckExemption::EventProvider exemptionprov; RepeatMode rm; public: - RepeatModule() : rm(this) {} + RepeatModule() + : exemptionprov(this) + , rm(this) + { + } void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { @@ -363,7 +369,9 @@ class RepeatModule : public Module if (!memb) return MOD_RES_PASSTHRU; - if (ServerInstance->OnCheckExemption(user, chan, "repeat") == MOD_RES_ALLOW) + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, chan, "repeat")); + if (res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; if (rm.MatchLine(memb, settings, text)) diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index e97e1b02f..1ff206ed1 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -24,6 +24,7 @@ #include "inspircd.h" #include "modules/account.h" +#include "modules/exemption.h" /** Channel mode +r - mark a channel as identified */ @@ -139,6 +140,7 @@ class AccountExtItemImpl : public AccountExtItem class ModuleServicesAccount : public Module, public Whois::EventListener { + CheckExemption::EventProvider exemptionprov; AChannel_R m1; AChannel_M m2; AUser_R m3; @@ -149,6 +151,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener public: ModuleServicesAccount() : Whois::EventListener(this) + , exemptionprov(this) , m1(this), m2(this), m3(this), m4(this), m5(this) , accountname(this) , checking_ban(false) @@ -196,7 +199,8 @@ class ModuleServicesAccount : public Module, public Whois::EventListener if (target_type == TYPE_CHANNEL) { Channel* c = (Channel*)dest; - ModResult res = ServerInstance->OnCheckExemption(user,c,"regmoderated"); + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "regmoderated")); if (c->IsModeSet(m2) && !is_registered && res != MOD_RES_ALLOW) { diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp index 592aeda90..6ad32bfc1 100644 --- a/src/modules/m_stripcolor.cpp +++ b/src/modules/m_stripcolor.cpp @@ -20,6 +20,7 @@ #include "inspircd.h" +#include "modules/exemption.h" /** Handles channel mode +S */ @@ -40,11 +41,15 @@ class UserStripColor : public SimpleUserModeHandler class ModuleStripColor : public Module { + CheckExemption::EventProvider exemptionprov; ChannelStripColor csc; UserStripColor usc; public: - ModuleStripColor() : csc(this), usc(this) + ModuleStripColor() + : exemptionprov(this) + , csc(this) + , usc(this) { } @@ -67,7 +72,8 @@ class ModuleStripColor : public Module else if (target_type == TYPE_CHANNEL) { Channel* t = (Channel*)dest; - ModResult res = ServerInstance->OnCheckExemption(user,t,"stripcolor"); + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, t, "stripcolor")); if (res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; @@ -91,12 +97,13 @@ class ModuleStripColor : public Module if (!IS_LOCAL(user)) return; - bool active = channel->GetExtBanStatus(user, 'S').check(!user->IsModeSet(csc)) - && ServerInstance->OnCheckExemption(user, channel, "stripcolor") != MOD_RES_ALLOW; - - if (active) + if (channel->GetExtBanStatus(user, 'S').check(!user->IsModeSet(csc))) { - InspIRCd::StripColor(partmessage); + ModResult res; + FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, channel, "stripcolor")); + + if (res != MOD_RES_ALLOW) + InspIRCd::StripColor(partmessage); } } |