]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_testcommand.cpp
fix little typo in syntax hint, type => action
[user/henk/code/inspircd.git] / src / modules / m_testcommand.cpp
index fe205ccc58d8d6412cc3685616d51d3339821e8e..a52fcc50765e0949ee3ce82a2249f655fd930aef 100644 (file)
@@ -1,69 +1,61 @@
-#include <stdio.h>
-
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
-
-/* $ModDesc: Povides a proof-of-concept test /WOOT command */
-
-Server *Srv;
-        
-
-void handle_woot(char **parameters, int pcnt, userrec *user)
-{
-       // this test command just accepts:
-       // /woot <text>
-       // and sends <text> to all opers with +s mode.
-       Srv->SendOpers(parameters[0]);
-}
-
-class ModuleTestCommand : public Module
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "inspircd.h"
+
+/* $ModDesc: Provides a pointless /dalinfo command, demo module */
+
+/** Handle /DALINFO
+ */
+class CommandDalinfo : public Command
 {
  public:
-       ModuleTestCommand()
-       {
-               Srv = new Server;
-               Srv->AddCommand("WOOT",handle_woot,0,1);
-       }
-       
-       virtual ~ModuleTestCommand()
-       {
-               delete Srv;
-       }
-       
-       virtual Version GetVersion()
+       /* Command 'dalinfo', takes no parameters and needs no special modes */
+       CommandDalinfo (InspIRCd* Instance) : Command(Instance,"DALINFO", 0, 0)
        {
-               return Version(1,0,0,0);
+               this->source = "m_testcommand.so";
        }
-       
-       virtual void OnUserConnect(userrec* user)
+
+       CmdResult Handle (const std::vector<std::string> &parameters, User *user)
        {
+               user->WriteServ("NOTICE %s :*** DALNet had nothing to do with it.", user->nick.c_str());
+               return CMD_FAILURE;
        }
-
 };
 
-
-class ModuleTestCommandFactory : public ModuleFactory
+class ModuleTestCommand : public Module
 {
+       CommandDalinfo* newcommand;
  public:
-       ModuleTestCommandFactory()
+       ModuleTestCommand(InspIRCd* Me)
+               : Module(Me)
        {
+               // Create a new command
+               newcommand = new CommandDalinfo(ServerInstance);
+               ServerInstance->AddCommand(newcommand);
+
        }
-       
-       ~ModuleTestCommandFactory()
+
+
+       virtual ~ModuleTestCommand()
        {
        }
-       
-       virtual Module * CreateModule()
+
+       virtual Version GetVersion()
        {
-               return new ModuleTestCommand;
+               return Version("$Id$", VF_VENDOR, API_VERSION);
        }
-       
 };
 
-
-extern "C" void * init_module( void )
-{
-       return new ModuleTestCommandFactory;
-}
+MODULE_INIT(ModuleTestCommand)