]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_knock.cpp
- Tear out a useless load of XLine clutters that did nothing much except confuse...
[user/henk/code/inspircd.git] / src / modules / m_knock.cpp
index a546a85ee6c3d71551c19f9a0e676ff14fc41db0..67aa50d49fb3248628062e16144395bdf1d1c618 100644 (file)
  */
 
 #include "inspircd.h"
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
 
 /* $ModDesc: Provides support for /KNOCK and mode +K */
 
 /** Handles the /KNOCK command
  */
-class cmd_knock : public command_t
+class CommandKnock : public Command
 {
  public:
-       cmd_knock (InspIRCd* Instance) : command_t(Instance,"KNOCK", 0, 2)
+       CommandKnock (InspIRCd* Instance) : Command(Instance,"KNOCK", 0, 2)
        {
                this->source = "m_knock.so";
                syntax = "<channel> <reason>";
+               TRANSLATE3(TR_TEXT, TR_TEXT, TR_END);
        }
        
-       CmdResult Handle (const char** parameters, int pcnt, userrec *user)
+       CmdResult Handle (const char** parameters, int pcnt, User *user)
        {
-               chanrec* c = ServerInstance->FindChan(parameters[0]);
+               Channel* c = ServerInstance->FindChan(parameters[0]);
 
                if (!c)
                {
@@ -39,7 +37,7 @@ class cmd_knock : public command_t
                        return CMD_FAILURE;
                }
 
-               std::string line = "";
+               std::string line;
 
                if (c->IsModeSet('K'))
                {
@@ -72,7 +70,7 @@ class Knock : public ModeHandler
  public:
        Knock(InspIRCd* Instance) : ModeHandler(Instance, 'K', 0, 0, false, MODETYPE_CHANNEL, false) { }
 
-       ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
                if (adding)
                {
@@ -97,16 +95,17 @@ class Knock : public ModeHandler
 
 class ModuleKnock : public Module
 {
-       cmd_knock* mycommand;
+       CommandKnock* mycommand;
        Knock* kn;
  public:
        ModuleKnock(InspIRCd* Me) : Module(Me)
        {
-               
                kn = new Knock(ServerInstance);
-               if (!ServerInstance->AddMode(kn, 'K'))
+
+               if (!ServerInstance->AddMode(kn))
                        throw ModuleException("Could not add new modes!");
-               mycommand = new cmd_knock(ServerInstance);
+
+               mycommand = new CommandKnock(ServerInstance);
                ServerInstance->AddCommand(mycommand);
        }
 
@@ -117,38 +116,13 @@ class ModuleKnock : public Module
        virtual ~ModuleKnock()
        {
                ServerInstance->Modes->DelMode(kn);
-               DELETE(kn);
+               delete kn;
        }
 
        virtual Version GetVersion()
        {
-               return Version(1,1,0,1,VF_COMMON|VF_VENDOR,API_VERSION);
+               return Version(1, 1, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
        }
 };
 
-// stuff down here is the module-factory stuff. For basic modules you can ignore this.
-
-class ModuleKnockFactory : public ModuleFactory
-{
- public:
-       ModuleKnockFactory()
-       {
-       }
-       
-       ~ModuleKnockFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleKnock(Me);
-       }
-       
-};
-
-
-extern "C" DllExport void * init_module( void )
-{
-       return new ModuleKnockFactory;
-}
-
+MODULE_INIT(ModuleKnock)