X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_blockcolor.cpp;h=43d0826dd7138954b28f61acb66d5bc00008bcd9;hb=2fcb5ff4389a9a82d253acdff02a388ddcf14653;hp=d2558285017acd603fa4ba3b39a030ba268e2f3d;hpb=349106f3f9f75d7f957fc5d1e71ca650f4807bb9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp index d25582850..43d0826dd 100644 --- a/src/modules/m_blockcolor.cpp +++ b/src/modules/m_blockcolor.cpp @@ -22,52 +22,38 @@ #include "inspircd.h" - -/* $ModDesc: Provides channel mode +c to block color */ - -/** Handles the +c channel mode - */ -class BlockColor : public SimpleChannelModeHandler -{ - public: - BlockColor(Module* Creator) : SimpleChannelModeHandler(Creator, "blockcolor", 'c') { } -}; +#include "modules/exemption.h" class ModuleBlockColor : public Module { - bool AllowChanOps; - BlockColor bc; + CheckExemption::EventProvider exemptionprov; + SimpleChannelModeHandler bc; public: - ModuleBlockColor() : bc(this) + ModuleBlockColor() + : exemptionprov(this) + , bc(this, "blockcolor", 'c') { } - void init() + void On005Numeric(std::map& tokens) CXX11_OVERRIDE { - ServerInstance->Modules->AddService(bc); - Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric }; - ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); + tokens["EXTBAN"].push_back('c'); } - virtual void On005Numeric(std::string &output) + ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE { - ServerInstance->AddExtBanChar('c'); - } - - virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) - { - if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user))) + if ((target.type == MessageTarget::TYPE_CHANNEL) && (IS_LOCAL(user))) { - Channel* c = (Channel*)dest; - ModResult res = ServerInstance->OnCheckExemption(user,c,"blockcolor"); + Channel* c = target.Get(); + ModResult res = CheckExemption::Call(exemptionprov, user, c, "blockcolor"); if (res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; - if (!c->GetExtBanStatus(user, 'c').check(!c->IsModeSet('c'))) + if (!c->GetExtBanStatus(user, 'c').check(!c->IsModeSet(bc))) { - for (std::string::iterator i = text.begin(); i != text.end(); i++) + for (std::string::iterator i = details.text.begin(); i != details.text.end(); i++) { switch (*i) { @@ -77,7 +63,7 @@ class ModuleBlockColor : public Module case 21: case 22: case 31: - user->WriteNumeric(404, "%s %s :Can't send colors to channel (+c set)",user->nick.c_str(), c->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send colors to channel (+c set)"); return MOD_RES_DENY; break; } @@ -87,16 +73,7 @@ class ModuleBlockColor : public Module return MOD_RES_PASSTHRU; } - virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) - { - return OnUserPreMessage(user,dest,target_type,text,status,exempt_list); - } - - virtual ~ModuleBlockColor() - { - } - - virtual Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("Provides channel mode +c to block color",VF_VENDOR); }