X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_blockcolor.cpp;h=25345506e5a517faae5273543584f4b26c973056;hb=e59cb85871f75b7603c63c6cd274d57536cf6794;hp=567bdb24951e961f1ee304a9062ed6706faace86;hpb=5267fb9d362aeb326c9e64f7171c957f76776f90;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp index 567bdb249..25345506e 100644 --- a/src/modules/m_blockcolor.cpp +++ b/src/modules/m_blockcolor.cpp @@ -22,21 +22,17 @@ #include "inspircd.h" - -/** 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 { - BlockColor bc; + CheckExemption::EventProvider exemptionprov; + SimpleChannelModeHandler bc; public: - ModuleBlockColor() : bc(this) + ModuleBlockColor() + : exemptionprov(this) + , bc(this, "blockcolor", 'c') { } @@ -45,31 +41,25 @@ class ModuleBlockColor : public Module tokens["EXTBAN"].push_back('c'); } - ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE { - 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(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) + // Block all control codes except \001 for CTCP + if ((*i >= 0) && (*i < 32) && (*i != 1)) { - case 2: - case 3: - case 15: - case 21: - case 22: - case 31: - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send colors to channel (+c set)"); - return MOD_RES_DENY; - break; + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send colors to channel (+c is set)"); + return MOD_RES_DENY; } } }