summaryrefslogtreecommitdiff
path: root/src/modules/m_knock.cpp
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-06-18 18:30:10 +0200
committerattilamolnar <attilamolnar@hush.com>2013-07-19 19:40:03 +0200
commitb954283ccc4253a6881513bbe7f743c39886d3b7 (patch)
tree56386d71e6132d06e8e4e786fba867a4945114b1 /src/modules/m_knock.cpp
parent5288eb159451aea53168c1a812a72594801f6421 (diff)
Replace hardcoded mode letters, part 2
This changes all remaining Channel::IsModeSet() and Channel::GetModeParameter() calls to use ModeReferences for modes that were created by other modules or the core
Diffstat (limited to 'src/modules/m_knock.cpp')
-rw-r--r--src/modules/m_knock.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index b440328bd..3aa49094e 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -25,10 +25,16 @@
*/
class CommandKnock : public Command
{
+ SimpleChannelModeHandler& noknockmode;
+ ChanModeReference inviteonlymode;
+
public:
bool sendnotice;
bool sendnumeric;
- CommandKnock(Module* Creator) : Command(Creator,"KNOCK", 2, 2)
+ CommandKnock(Module* Creator, SimpleChannelModeHandler& Noknockmode)
+ : Command(Creator,"KNOCK", 2, 2)
+ , noknockmode(Noknockmode)
+ , inviteonlymode(Creator, "inviteonly")
{
syntax = "<channel> <reason>";
Penalty = 5;
@@ -49,13 +55,13 @@ class CommandKnock : public Command
return CMD_FAILURE;
}
- if (c->IsModeSet('K'))
+ if (c->IsModeSet(noknockmode))
{
user->WriteNumeric(480, "%s :Can't KNOCK on %s, +K is set.",user->nick.c_str(), c->name.c_str());
return CMD_FAILURE;
}
- if (!c->IsModeSet('i'))
+ if (!c->IsModeSet(inviteonlymode))
{
user->WriteNumeric(480, "%s :Can't KNOCK on %s, channel is not invite only so knocking is pointless!",user->nick.c_str(), c->name.c_str());
return CMD_FAILURE;
@@ -77,20 +83,15 @@ class CommandKnock : public Command
}
};
-/** Handles channel mode +K
- */
-class Knock : public SimpleChannelModeHandler
-{
- public:
- Knock(Module* Creator) : SimpleChannelModeHandler(Creator, "noknock", 'K') { }
-};
-
class ModuleKnock : public Module
{
+ SimpleChannelModeHandler kn;
CommandKnock cmd;
- Knock kn;
+
public:
- ModuleKnock() : cmd(this), kn(this)
+ ModuleKnock()
+ : kn(this, "noknock", 'K')
+ , cmd(this, kn)
{
}