From 7892c8a0313c50d8138942ff3b112691caf05a2f Mon Sep 17 00:00:00 2001 From: danieldg Date: Sun, 13 Sep 2009 20:31:23 +0000 Subject: Replace OnAccessCheck with OnPreMode to remove a number of redundant checks git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11700 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_nokicks.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'src/modules/m_nokicks.cpp') diff --git a/src/modules/m_nokicks.cpp b/src/modules/m_nokicks.cpp index 4af76e0d8..1324a7c03 100644 --- a/src/modules/m_nokicks.cpp +++ b/src/modules/m_nokicks.cpp @@ -31,43 +31,40 @@ class ModuleNoKicks : public Module { if (!ServerInstance->Modes->AddMode(&nk)) throw ModuleException("Could not add new modes!"); - Implementation eventlist[] = { I_OnAccessCheck, I_On005Numeric }; + Implementation eventlist[] = { I_OnUserPreKick, I_On005Numeric }; ServerInstance->Modules->Attach(eventlist, this, 2); } - virtual void On005Numeric(std::string &output) + void On005Numeric(std::string &output) { ServerInstance->AddExtBanChar('Q'); } - virtual ModResult OnAccessCheck(User* source,User* dest,Channel* channel,int access_type) + ModResult OnUserPreKick(User* source, Membership* memb, const std::string &reason) { - if (access_type == AC_KICK) + if (!memb->chan->GetExtBanStatus(source, 'Q').check(!memb->chan->IsModeSet('Q'))) { - if (!channel->GetExtBanStatus(source, 'Q').check(!channel->IsModeSet('Q'))) + if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server)) { - if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server)) - { - // ulines can still kick with +Q in place - return MOD_RES_PASSTHRU; - } - else - { - // nobody else can (not even opers with override, and founders) - source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Can't kick user %s from channel (+Q set)",source->nick.c_str(), channel->name.c_str(), dest->nick.c_str()); - return MOD_RES_DENY; - } + // ulines can still kick with +Q in place + return MOD_RES_PASSTHRU; + } + else + { + // nobody else can (not even opers with override, and founders) + source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Can't kick user %s from channel (+Q set)",source->nick.c_str(), memb->chan->name.c_str(), memb->user->nick.c_str()); + return MOD_RES_DENY; } } return MOD_RES_PASSTHRU; } - virtual ~ModuleNoKicks() + ~ModuleNoKicks() { ServerInstance->Modes->DelMode(&nk); } - virtual Version GetVersion() + Version GetVersion() { return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION); } -- cgit v1.2.3