]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_setname.cpp
Added ability to send and receive a challenge, dont do anything with it yet
[user/henk/code/inspircd.git] / src / modules / m_setname.cpp
index 4ae8f5faeab132b7364c7dacb45e9dc9b1e9b7a6..bb78d6a0f29b9b42877aa9e1763e3b0d0b34f639 100644 (file)
@@ -1,11 +1,14 @@
-/*
- *  SETNAME module for InspIRCD
- *  Author: brain
- *  Version: 1.0.0.0
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
  *
- *  Syntax: /SETNAME [new name]
- *  Changes the user's GECOS who issues the command
- *  
+ *  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 <stdio.h>
 #include "channels.h"
 #include "modules.h"
 
+#include "inspircd.h"
+
 /* $ModDesc: Provides support for the SETNAME command */
 
-Server *Srv;
-        
-void handle_setname(char **parameters, int pcnt, userrec *user)
+
+
+class cmd_setname : public command_t
 {
-       std::string = "";
-       for (int i = 0; i < pcnt-1; i++)
+ public:
+       cmd_setname (InspIRCd* Instance) : command_t(Instance,"SETNAME", 0, 1)
        {
-               line = line + std::string(parameters[i]);
+               this->source = "m_setname.so";
+               syntax = "<new-gecos>";
        }
-       line = line + std::string(parameters[pcnt-1]);
-       strncpy(user->fullname,parameters[0],127);
-}
+
+       CmdResult Handle (const char** parameters, int pcnt, userrec *user)
+       {
+               std::string line = "";
+               for (int i = 0; i < pcnt-1; i++)
+               {
+                       line = line + std::string(parameters[i]) + " ";
+               }
+               line = line + std::string(parameters[pcnt-1]);
+               user->ChangeName(line.c_str());
+
+               return CMD_SUCCESS;
+       }
+};
 
 
 class ModuleSetName : public Module
 {
+       cmd_setname*    mycommand;
  public:
-       ModuleSetName()
+       ModuleSetName(InspIRCd* Me)
+               : Module::Module(Me)
        {
-               Srv = new Server;
-               Srv->AddCommand("SETNAME",handle_setname,0,1);
+               
+               mycommand = new cmd_setname(ServerInstance);
+               ServerInstance->AddCommand(mycommand);
        }
        
        virtual ~ModuleSetName()
        {
-               delete Srv;
        }
        
        virtual Version GetVersion()
        {
-               return Version(1,0,0,0);
+               return Version(1,1,0,1,VF_VENDOR,API_VERSION);
        }
        
 };
@@ -64,9 +83,9 @@ class ModuleSetNameFactory : public ModuleFactory
        {
        }
        
-       virtual Module * CreateModule()
+       virtual Module * CreateModule(InspIRCd* Me)
        {
-               return new ModuleSetName;
+               return new ModuleSetName(Me);
        }
        
 };