From: attilamolnar Date: Sun, 24 Jun 2012 15:10:11 +0000 (+0200) Subject: m_noctcp Use SimpleChannelModeHandler, reorder checks X-Git-Tag: v2.0.23~681 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=dffec4281598e6034ad5c0ee075c858d3579d903;p=user%2Fhenk%2Fcode%2Finspircd.git m_noctcp Use SimpleChannelModeHandler, reorder checks --- diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp index 0b4e39764..b73950579 100644 --- a/src/modules/m_noctcp.cpp +++ b/src/modules/m_noctcp.cpp @@ -23,32 +23,10 @@ /* $ModDesc: Provides support for unreal-style channel mode +C */ -class NoCTCP : public ModeHandler +class NoCTCP : public SimpleChannelModeHandler { public: - NoCTCP(Module* Creator) : ModeHandler(Creator, "noctcp", 'C', PARAM_NONE, MODETYPE_CHANNEL) { } - - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) - { - if (adding) - { - if (!channel->IsModeSet('C')) - { - channel->SetMode('C',true); - return MODEACTION_ALLOW; - } - } - else - { - if (channel->IsModeSet('C')) - { - channel->SetMode('C',false); - return MODEACTION_ALLOW; - } - } - - return MODEACTION_DENY; - } + NoCTCP(Module* Creator) : SimpleChannelModeHandler(Creator, "noctcp", 'C') { } }; class ModuleNoCTCP : public Module @@ -86,21 +64,20 @@ class ModuleNoCTCP : public Module if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user))) { Channel* c = (Channel*)dest; - ModResult res = ServerInstance->OnCheckExemption(user,c,"noctcp"); + if (!c->IsModeSet('C')) + return MOD_RES_PASSTHRU; + + if ((text.empty()) || (text[0] != '\001') || (strncmp(text.c_str(),"\1ACTION ",8))) + return MOD_RES_PASSTHRU; + ModResult res = ServerInstance->OnCheckExemption(user,c,"noctcp"); if (res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; - if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet('C'))) + if (!c->GetExtBanStatus(user, 'C')) { - if ((text.length()) && (text[0] == '\1')) - { - if (strncmp(text.c_str(),"\1ACTION ",8)) - { - user->WriteNumeric(ERR_NOCTCPALLOWED, "%s %s :Can't send CTCP to channel (+C set)",user->nick.c_str(), c->name.c_str()); - return MOD_RES_DENY; - } - } + user->WriteNumeric(ERR_NOCTCPALLOWED, "%s %s :Can't send CTCP to channel (+C set)",user->nick.c_str(), c->name.c_str()); + return MOD_RES_DENY; } } return MOD_RES_PASSTHRU;