summaryrefslogtreecommitdiff
path: root/modules/commands/cs_akick.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-12-28 15:59:33 -0500
committerAdam <Adam@anope.org>2012-12-28 15:59:33 -0500
commit6b1f323bb519009048a94c8bb3d003288a339345 (patch)
treeb30ad2793adca8e63f9de0b8a45295a4f3d56dea /modules/commands/cs_akick.cpp
parent761849083da3a523eeb3b2293311cfee1c29df35 (diff)
Move some of CheckKick to the respective modules
Diffstat (limited to 'modules/commands/cs_akick.cpp')
-rw-r--r--modules/commands/cs_akick.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp
index 52d0ecd76..28bc54857 100644
--- a/modules/commands/cs_akick.cpp
+++ b/modules/commands/cs_akick.cpp
@@ -502,6 +502,44 @@ class CSAKick : public Module
{
this->SetAuthor("Anope");
+ Implementation i[] = { I_OnCheckKick };
+ ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
+ }
+
+ EventReturn OnCheckKick(User *u, ChannelInfo *ci, Anope::string &mask, Anope::string &reason) anope_override
+ {
+ if (ci->c->MatchesList(u, CMODE_EXCEPT))
+ return EVENT_CONTINUE;
+
+ for (unsigned j = 0, end = ci->GetAkickCount(); j < end; ++j)
+ {
+ AutoKick *autokick = ci->GetAkick(j);
+ bool kick = false;
+
+ if (autokick->HasFlag(AK_ISNICK))
+ {
+ if (autokick->nc == u->Account())
+ kick = true;
+ }
+ else
+ {
+ Entry akick_mask(CMODE_BEGIN, autokick->mask);
+ if (akick_mask.Matches(u))
+ kick = true;
+ }
+
+ if (kick)
+ {
+ Log(LOG_DEBUG_2) << u->nick << " matched akick " << (autokick->HasFlag(AK_ISNICK) ? autokick->nc->display : autokick->mask);
+ autokick->last_used = Anope::CurTime;
+ if (!autokick->HasFlag(AK_ISNICK))
+ mask = autokick->mask;
+ reason = autokick->reason.empty() ? Config->CSAutokickReason : autokick->reason;
+ return EVENT_STOP;
+ }
+ }
+
+ return EVENT_CONTINUE;
}
};