X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_nokicks.cpp;h=dbfa0c2eab71fcd1af25835fb3dbff40b8d3fc3a;hb=77bb8528a69735ba59e0cd1ac2801063343a6187;hp=216fa3ae21791a3114c709afa7c39ec6a118c39b;hpb=3f546994609ed717a63222cb16c5359a09ebff35;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_nokicks.cpp b/src/modules/m_nokicks.cpp index 216fa3ae2..dbfa0c2ea 100644 --- a/src/modules/m_nokicks.cpp +++ b/src/modules/m_nokicks.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * InspIRCd: (C) 2002-2008 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see @@ -12,38 +12,13 @@ */ #include "inspircd.h" -#include "users.h" -#include "channels.h" -#include "modules.h" /* $ModDesc: Provides support for unreal-style channel mode +Q */ -class NoKicks : public ModeHandler +class NoKicks : public SimpleChannelModeHandler { public: - NoKicks(InspIRCd* Instance) : ModeHandler(Instance, 'Q', 0, 0, false, MODETYPE_CHANNEL, false) { } - - ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) - { - if (adding) - { - if (!channel->IsModeSet('Q')) - { - channel->SetMode('Q',true); - return MODEACTION_ALLOW; - } - } - else - { - if (channel->IsModeSet('Q')) - { - channel->SetMode('Q',false); - return MODEACTION_ALLOW; - } - } - - return MODEACTION_DENY; - } + NoKicks(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'Q') { } }; class ModuleNoKicks : public Module @@ -58,22 +33,20 @@ class ModuleNoKicks : public Module { nk = new NoKicks(ServerInstance); - if (!ServerInstance->AddMode(nk, 'Q')) + if (!ServerInstance->Modes->AddMode(nk)) throw ModuleException("Could not add new modes!"); + Implementation eventlist[] = { I_OnAccessCheck }; + ServerInstance->Modules->Attach(eventlist, this, 1); } - void Implements(char* List) - { - List[I_OnAccessCheck] = 1; - } - virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type) + virtual int OnAccessCheck(User* source,User* dest,Channel* channel,int access_type) { if (access_type == AC_KICK) { if (channel->IsModeSet('Q')) { - if ((ServerInstance->ULine(source->nick)) || (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 ACR_ALLOW; @@ -81,7 +54,7 @@ class ModuleNoKicks : public Module else { // nobody else can (not even opers with override, and founders) - source->WriteServ("484 %s %s :Can't kick user %s from channel (+Q set)",source->nick, channel->name,dest->nick); + source->WriteNumeric(484, "%s %s :Can't kick user %s from channel (+Q set)",source->nick.c_str(), channel->name,dest->nick.c_str()); return ACR_DENY; } } @@ -92,14 +65,14 @@ class ModuleNoKicks : public Module virtual ~ModuleNoKicks() { ServerInstance->Modes->DelMode(nk); - DELETE(nk); + delete nk; } virtual Version GetVersion() { - return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION); + return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION); } }; -MODULE_INIT(ModuleNoKicks); +MODULE_INIT(ModuleNoKicks)