summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-10-21 16:34:48 +0100
committerPeter Powell <petpow@saberuk.com>2017-10-21 16:34:48 +0100
commitdcd3438011d59aa4de4df64abf06bca1cbf36859 (patch)
tree86d9da14ef7258831b25d8aac70383d2964d3a9f
parent9f7c187c518466114cb3e3b51979d2c63c2ce7a0 (diff)
Add a helper function for calling the OnCheckExemption event.
-rw-r--r--include/modules/exemption.h17
-rw-r--r--src/coremods/core_channel/cmd_topic.cpp3
-rw-r--r--src/modules/m_auditorium.cpp6
-rw-r--r--src/modules/m_blockcaps.cpp3
-rw-r--r--src/modules/m_blockcolor.cpp3
-rw-r--r--src/modules/m_censor.cpp3
-rw-r--r--src/modules/m_chanfilter.cpp3
-rw-r--r--src/modules/m_messageflood.cpp3
-rw-r--r--src/modules/m_nickflood.cpp4
-rw-r--r--src/modules/m_noctcp.cpp3
-rw-r--r--src/modules/m_nonicks.cpp3
-rw-r--r--src/modules/m_nonotice.cpp2
-rw-r--r--src/modules/m_repeat.cpp3
-rw-r--r--src/modules/m_services_account.cpp3
-rw-r--r--src/modules/m_stripcolor.cpp6
15 files changed, 34 insertions, 31 deletions
diff --git a/include/modules/exemption.h b/include/modules/exemption.h
index 2f4ee02fc..b590a5797 100644
--- a/include/modules/exemption.h
+++ b/include/modules/exemption.h
@@ -25,6 +25,16 @@ namespace CheckExemption
{
class EventListener;
class EventProvider;
+
+ /** Helper function for calling the CheckExemption::EventListener::OnCheckExemption event.
+ * @param prov The CheckExemption::EventProvider which is calling the event.
+ * @param user The user to check exemption for.
+ * @param chan The channel to check exemption on.
+ * @param restriction The restriction to check for.
+ * @return Either MOD_RES_ALLOW if the exemption was confirmed, MOD_RES_DENY if the exemption was
+ * denied or MOD_RES_PASSTHRU if no module handled the event.
+ */
+ inline ModResult Call(const CheckExemption::EventProvider& prov, User* user, Channel* chan, const std::string& restriction);
}
class CheckExemption::EventListener
@@ -56,3 +66,10 @@ class CheckExemption::EventProvider
{
}
};
+
+inline ModResult CheckExemption::Call(const CheckExemption::EventProvider& prov, User* user, Channel* chan, const std::string& restriction)
+{
+ ModResult result;
+ FIRST_MOD_RESULT_CUSTOM(prov, CheckExemption::EventListener, OnCheckExemption, result, (user, chan, restriction));
+ return result;
+}
diff --git a/src/coremods/core_channel/cmd_topic.cpp b/src/coremods/core_channel/cmd_topic.cpp
index ec6ed9744..835ac82ed 100644
--- a/src/coremods/core_channel/cmd_topic.cpp
+++ b/src/coremods/core_channel/cmd_topic.cpp
@@ -76,8 +76,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters,
}
if (c->IsModeSet(topiclockmode))
{
- ModResult MOD_RESULT;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, MOD_RESULT, (user, c, "topiclock"));
+ ModResult MOD_RESULT = CheckExemption::Call(exemptionprov, user, c, "topiclock");
if (!MOD_RESULT.check(c->GetPrefixValue(user) >= HALFOP_VALUE))
{
user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, "You do not have access to change the topic on this channel");
diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp
index cd257eff3..692b3eba4 100644
--- a/src/modules/m_auditorium.cpp
+++ b/src/modules/m_auditorium.cpp
@@ -66,8 +66,7 @@ class ModuleAuditorium : public Module
if (!memb->chan->IsModeSet(&aum))
return true;
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (memb->user, memb->chan, "auditorium-vis"));
+ ModResult res = CheckExemption::Call(exemptionprov, memb->user, memb->chan, "auditorium-vis");
return res.check(OpsVisible && memb->getRank() >= OP_VALUE);
}
@@ -83,8 +82,7 @@ class ModuleAuditorium : public Module
return true;
// Can you see the list by permission?
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (issuer, memb->chan, "auditorium-see"));
+ ModResult res = CheckExemption::Call(exemptionprov, 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 c26d92caa..dc0bdf974 100644
--- a/src/modules/m_blockcaps.cpp
+++ b/src/modules/m_blockcaps.cpp
@@ -60,8 +60,7 @@ public:
return MOD_RES_PASSTHRU;
Channel* c = (Channel*)dest;
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "blockcaps"));
+ ModResult res = CheckExemption::Call(exemptionprov, 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 7c961d96a..175c3b793 100644
--- a/src/modules/m_blockcolor.cpp
+++ b/src/modules/m_blockcolor.cpp
@@ -54,8 +54,7 @@ class ModuleBlockColor : public Module
if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
{
Channel* c = (Channel*)dest;
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "blockcolor"));
+ ModResult res = CheckExemption::Call(exemptionprov, 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 56639b298..a2f671772 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -70,8 +70,7 @@ class ModuleCensor : public Module
{
Channel* c = (Channel*)dest;
active = c->IsModeSet(cc);
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "censor"));
+ ModResult res = CheckExemption::Call(exemptionprov, 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 b642cb933..90e266fc3 100644
--- a/src/modules/m_chanfilter.cpp
+++ b/src/modules/m_chanfilter.cpp
@@ -87,8 +87,7 @@ class ModuleChanFilter : public Module
return MOD_RES_PASSTHRU;
Channel* chan = static_cast<Channel*>(dest);
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, chan, "filter"));
+ ModResult res = CheckExemption::Call(exemptionprov, user, chan, "filter");
if (!IS_LOCAL(user) || res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index 9d119b6c3..404c9b861 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -124,8 +124,7 @@ class ModuleMsgFlood : public Module
if ((!IS_LOCAL(user)) || !dest->IsModeSet(mf))
return MOD_RES_PASSTHRU;
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, dest, "flood"));
+ ModResult res = CheckExemption::Call(exemptionprov, user, dest, "flood");
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp
index a4a87f691..bf36fb430 100644
--- a/src/modules/m_nickflood.cpp
+++ b/src/modules/m_nickflood.cpp
@@ -148,7 +148,7 @@ class ModuleNickFlood : public Module
nickfloodsettings *f = nf.ext.get(channel);
if (f)
{
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, channel, "nickflood"));
+ res = CheckExemption::Call(exemptionprov, user, channel, "nickflood");
if (res == MOD_RES_ALLOW)
continue;
@@ -187,7 +187,7 @@ class ModuleNickFlood : public Module
nickfloodsettings *f = nf.ext.get(channel);
if (f)
{
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, channel, "nickflood"));
+ res = CheckExemption::Call(exemptionprov, user, channel, "nickflood");
if (res == MOD_RES_ALLOW)
return;
diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp
index 713964328..4fc844b74 100644
--- a/src/modules/m_noctcp.cpp
+++ b/src/modules/m_noctcp.cpp
@@ -53,8 +53,7 @@ class ModuleNoCTCP : public Module
if ((text.empty()) || (text[0] != '\001') || (!strncmp(text.c_str(),"\1ACTION ", 8)) || (text == "\1ACTION\1") || (text == "\1ACTION"))
return MOD_RES_PASSTHRU;
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "noctcp"));
+ ModResult res = CheckExemption::Call(exemptionprov, 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 c6de17e89..91a1303c6 100644
--- a/src/modules/m_nonicks.cpp
+++ b/src/modules/m_nonicks.cpp
@@ -56,8 +56,7 @@ class ModuleNoNickChange : public Module
{
Channel* curr = (*i)->chan;
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, curr, "nonick"));
+ ModResult res = CheckExemption::Call(exemptionprov, user, curr, "nonick");
if (res == MOD_RES_ALLOW)
continue;
diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp
index ec5be9517..f6496120b 100644
--- a/src/modules/m_nonotice.cpp
+++ b/src/modules/m_nonotice.cpp
@@ -53,7 +53,7 @@ class ModuleNoNotice : public Module
Channel* c = (Channel*)dest;
if (!c->GetExtBanStatus(user, 'T').check(!c->IsModeSet(nt)))
{
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "nonotice"));
+ res = CheckExemption::Call(exemptionprov, 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 6c34648e0..aa7dc762b 100644
--- a/src/modules/m_repeat.cpp
+++ b/src/modules/m_repeat.cpp
@@ -369,8 +369,7 @@ class RepeatModule : public Module
if (!memb)
return MOD_RES_PASSTHRU;
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, chan, "repeat"));
+ ModResult res = CheckExemption::Call(exemptionprov, user, chan, "repeat");
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index ac5730374..249ba35ce 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -213,8 +213,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
if (target_type == TYPE_CHANNEL)
{
Channel* c = (Channel*)dest;
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "regmoderated"));
+ ModResult res = CheckExemption::Call(exemptionprov, 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 6ad32bfc1..9afe7132c 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -72,8 +72,7 @@ class ModuleStripColor : public Module
else if (target_type == TYPE_CHANNEL)
{
Channel* t = (Channel*)dest;
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, t, "stripcolor"));
+ ModResult res = CheckExemption::Call(exemptionprov, user, t, "stripcolor");
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
@@ -99,8 +98,7 @@ class ModuleStripColor : public Module
if (channel->GetExtBanStatus(user, 'S').check(!user->IsModeSet(csc)))
{
- ModResult res;
- FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, channel, "stripcolor"));
+ ModResult res = CheckExemption::Call(exemptionprov, user, channel, "stripcolor");
if (res != MOD_RES_ALLOW)
InspIRCd::StripColor(partmessage);