]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_testcommand.cpp
Fix new millisec /map to compile on windows, by ifndef gettimeofday out reverting...
[user/henk/code/inspircd.git] / src / modules / m_testcommand.cpp
index 72ca9e16ac79b3290d164fa5ee81953db76e84c4..842dd3a55fe768ec7d0c8bca56741266aae2dc72 100644 (file)
@@ -1,71 +1,66 @@
-#include <stdio.h>
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2007 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"
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
 
-/* $ModDesc: Povides a proof-of-concept test /WOOT command */
+/* $ModDesc: Provides a pointless /dalinfo command, demo module */
 
-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.
-       // NB: The ':' is *REQUIRED* otherwise the parser will
-       // split the line into multiple parameters[]!
-       Srv->SendOpers(parameters[0]);
-}
-
-class ModuleTestCommand : public Module
+/** Handle /DALINFO
+ */
+class cmd_dalinfo : public command_t
 {
  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 */
+       cmd_dalinfo (InspIRCd* Instance) : command_t(Instance,"DALINFO", 0, 0)
        {
-               return Version(1,0,0,0);
+               this->source = "m_testcommand.so";
        }
-       
-       virtual void OnUserConnect(userrec* user)
+
+       CmdResult Handle (const char** parameters, int pcnt, userrec *user)
        {
+               user->WriteServ("NOTICE %s :*** DALNet had nothing to do with it.", user->nick);
+               return CMD_FAILURE;
        }
-
 };
 
-
-class ModuleTestCommandFactory : public ModuleFactory
+class ModuleTestCommand : public Module
 {
+       cmd_dalinfo* newcommand;
  public:
-       ModuleTestCommandFactory()
+       ModuleTestCommand(InspIRCd* Me)
+               : Module(Me)
        {
+               // Create a new command
+               newcommand = new cmd_dalinfo(ServerInstance);
+               ServerInstance->AddCommand(newcommand);
        }
-       
-       ~ModuleTestCommandFactory()
+
+       void Implements(char* List)
        {
        }
-       
-       virtual Module * CreateModule()
+
+       virtual ~ModuleTestCommand()
        {
-               return new ModuleTestCommand;
        }
-       
-};
 
+       virtual Version GetVersion()
+       {
+               return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
+       }
+};
 
-extern "C" void * init_module( void )
-{
-       return new ModuleTestCommandFactory;
-}
+MODULE_INIT(ModuleTestCommand)