summaryrefslogtreecommitdiff
path: root/src/modules/m_noctcp.cpp
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-06-24 17:10:11 +0200
committerRobin Burchell <robin+git@viroteck.net>2012-06-30 00:18:48 +0200
commitdffec4281598e6034ad5c0ee075c858d3579d903 (patch)
treee1b2aec33f71d8899504e59a0289855597649f2a /src/modules/m_noctcp.cpp
parentad9d6ad02a7f6f35e02870f50035d54bc2231f04 (diff)
m_noctcp Use SimpleChannelModeHandler, reorder checks
Diffstat (limited to 'src/modules/m_noctcp.cpp')
-rw-r--r--src/modules/m_noctcp.cpp45
1 files changed, 11 insertions, 34 deletions
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 &parameter, 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;