X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_knock.cpp;h=36a6933dc511aa3e057dce37a29116dad9c877c0;hb=9d75ba35743eb8f44a2d7beb8e08aa43c13f5d2e;hp=ef3b617cda1b3822883e7d38c3701902f9837f59;hpb=ac7defcd3e52695dcf5e5150e9fe3e1624205e64;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index ef3b617cd..36a6933dc 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -21,20 +21,23 @@ #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 = " "; Penalty = 5; - TRANSLATE3(TR_TEXT, TR_TEXT, TR_END); } CmdResult Handle (const std::vector ¶meters, User *user) @@ -52,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; @@ -70,7 +73,7 @@ class CommandKnock : public Command if (sendnumeric) c->WriteChannelWithServ(ServerInstance->Config->ServerName, "710 %s %s %s :is KNOCKing: %s", c->name.c_str(), c->name.c_str(), user->GetFullHost().c_str(), parameters[1].c_str()); - user->WriteServ("NOTICE %s :KNOCKing on %s", user->nick.c_str(), c->name.c_str()); + user->WriteNotice("KNOCKing on " + c->name); return CMD_SUCCESS; } @@ -80,34 +83,19 @@ 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) - { - } - void init() + public: + ModuleKnock() + : kn(this, "noknock", 'K') + , cmd(this, kn) { - if (!ServerInstance->Modes->AddMode(&kn)) - throw ModuleException("Could not add new modes!"); - ServerInstance->AddCommand(&cmd); - - ServerInstance->Modules->Attach(I_OnRehash, this); - OnRehash(NULL); } - void OnRehash(User* user) + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { std::string knocknotify = ServerInstance->Config->ConfValue("knock")->getString("notify"); irc::string notify(knocknotify.c_str()); @@ -129,7 +117,7 @@ class ModuleKnock : public Module } } - virtual Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("Provides support for /KNOCK and channel mode +K", VF_OPTCOMMON | VF_VENDOR); }