]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chgident.cpp
This is better now.
[user/henk/code/inspircd.git] / src / modules / m_chgident.cpp
index 7efe2e755120674898af354dadccd5fa81926da1..e36b5332980797386adeee9597d336f981069dce 100644 (file)
@@ -1,25 +1,23 @@
 #include <string>
 #include "users.h"
 #include "modules.h"
-#include "helperfuncs.h"
+
 #include "inspircd.h"
 
 /* $ModDesc: Provides support for the CHGIDENT command */
 
-extern InspIRCd* ServerInstance;
-
+/** Handle /CHGIDENT
+ */
 class cmd_chgident : public command_t
 {
-       Server* Srv;
  public:
-       cmd_chgident(Server* serv) : command_t("CHGIDENT", 'o', 2)
+       cmd_chgident (InspIRCd* Instance) : command_t(Instance,"CHGIDENT", 'o', 2)
        {
                this->source = "m_chgident.so";
-               Srv = serv;
                syntax = "<nick> <newident>";
        }
        
-       void Handle(const char** parameters, int pcnt, userrec *user)
+       CmdResult Handle(const char** parameters, int pcnt, userrec *user)
        {
                userrec* dest = ServerInstance->FindNick(parameters[0]);
 
@@ -28,15 +26,17 @@ class cmd_chgident : public command_t
                        if(!ServerInstance->IsIdent(parameters[1]))
                        {
                                user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick);
-                               return;
+                               return CMD_FAILURE;
                        }
-               
-                       ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident from '%s' to '%s'", user->nick, dest->nick, dest->ident, parameters[1]);
-                       strlcpy(dest->ident, parameters[1], IDENTMAX+2);
+
+                       dest->ChangeIdent(parameters[1]);
+                       ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident to '%s'", user->nick, dest->nick, dest->ident);
+                       return CMD_SUCCESS;
                }
                else
                {
                        user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]);
+                       return CMD_FAILURE;
                }
        }
 };
@@ -46,11 +46,12 @@ class ModuleChgIdent : public Module
 {
        cmd_chgident* mycommand;
        
+       
 public:
-       ModuleChgIdent(Server* Me) : Module::Module(Me)
+       ModuleChgIdent(InspIRCd* Me) : Module::Module(Me)
        {
-               mycommand = new cmd_chgident(Me);
-               Me->AddCommand(mycommand);
+               mycommand = new cmd_chgident(ServerInstance);
+               ServerInstance->AddCommand(mycommand);
        }
        
        virtual ~ModuleChgIdent()
@@ -59,7 +60,7 @@ public:
        
        virtual Version GetVersion()
        {
-               return Version(1,0,0,0,VF_VENDOR);
+               return Version(1,1,0,0,VF_VENDOR,API_VERSION);
        }
        
 };
@@ -77,7 +78,7 @@ class ModuleChgIdentFactory : public ModuleFactory
        {
        }
        
-       virtual Module * CreateModule(Server* Me)
+       virtual Module * CreateModule(InspIRCd* Me)
        {
                return new ModuleChgIdent(Me);
        }