]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chgname.cpp
Socket engine tweaks to fix a glitch, and improvements to new m_ident
[user/henk/code/inspircd.git] / src / modules / m_chgname.cpp
index d25e51426d4f34d4a8879f17c23c7138082e1c42..987678b5bda563530799eb53f2f22fce7087a0e6 100644 (file)
  */
 
 #include "inspircd.h"
-#include "users.h"
-#include "modules.h"
 
 /* $ModDesc: Provides support for the CHGNAME command */
 
 /** Handle /CHGNAME
  */
-class cmd_chgname : public command_t
+class cmd_chgname : public Command
 {
  public:
-       cmd_chgname (InspIRCd* Instance) : command_t(Instance,"CHGNAME", 'o', 2)
+       cmd_chgname (InspIRCd* Instance) : Command(Instance,"CHGNAME", 'o', 2)
        {
                this->source = "m_chgname.so";
                syntax = "<nick> <newname>";
+               TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
        }
        
-       CmdResult Handle(const char** parameters, int pcnt, userrec *user)
+       CmdResult Handle(const char** parameters, int pcnt, User *user)
        {
-               userrec* dest = ServerInstance->FindNick(parameters[0]);
+               User* dest = ServerInstance->FindNick(parameters[0]);
 
                if (!dest)
                {
                        user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]);
                        return CMD_FAILURE;
                }
-
+               
+               if (!*parameters[1])
+               {
+                       user->WriteServ("NOTICE %s :*** GECOS must be specified", user->nick);
+                       return CMD_FAILURE;
+               }
+               
+               if (strlen(parameters[1]) > MAXGECOS)
+               {
+                       user->WriteServ("NOTICE %s :*** GECOS too long", user->nick);
+                       return CMD_FAILURE;
+               }
+               
                if (IS_LOCAL(dest))
                {
                        dest->ChangeName(parameters[1]);
@@ -69,34 +80,9 @@ public:
        
        virtual Version GetVersion()
        {
-               return Version(1,1,0,0,VF_VENDOR,API_VERSION);
-       }
-       
-};
-
-// stuff down here is the module-factory stuff. For basic modules you can ignore this.
-
-class ModuleChgNameFactory : public ModuleFactory
-{
- public:
-       ModuleChgNameFactory()
-       {
-       }
-       
-       ~ModuleChgNameFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleChgName(Me);
+               return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
        }
        
 };
 
-
-extern "C" DllExport void * init_module( void )
-{
-       return new ModuleChgNameFactory;
-}
-
+MODULE_INIT(ModuleChgName)