]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_knock.cpp
m_spanningtree Remove SpanningTreeUtilities* fields and parameters
[user/henk/code/inspircd.git] / src / modules / m_knock.cpp
index 4978f66292cb4af4def649f9066e50a2cf192589..96ea66d7b0e505294a6d8557255caebd02ce2b6b 100644 (file)
 
 #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;
@@ -51,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;
@@ -79,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)
        {
        }
 
@@ -101,7 +100,6 @@ class ModuleKnock : public Module
                ServerInstance->Modules->AddService(kn);
                ServerInstance->Modules->AddService(cmd);
 
-               ServerInstance->Modules->Attach(I_OnRehash, this);
                OnRehash(NULL);
        }