#include "inspircd.h"
-/* $ModDesc: Provides support for /KNOCK and channel mode +K */
-
/** Handles the /KNOCK command
*/
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;
- TRANSLATE3(TR_TEXT, TR_TEXT, TR_END);
}
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
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;
}
};
-/** 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)
{
}
ServerInstance->Modules->AddService(kn);
ServerInstance->Modules->AddService(cmd);
- ServerInstance->Modules->Attach(I_OnRehash, this);
OnRehash(NULL);
}