]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chgname.cpp
Fix potential for duplicate SID if the SID is auto generated.
[user/henk/code/inspircd.git] / src / modules / m_chgname.cpp
index d25e51426d4f34d4a8879f17c23c7138082e1c42..ddb38567f195c42fbffe490b767e278498f07054 100644 (file)
@@ -12,8 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "users.h"
-#include "modules.h"
 
 /* $ModDesc: Provides support for the CHGNAME command */
 
@@ -26,6 +24,7 @@ class cmd_chgname : public command_t
        {
                this->source = "m_chgname.so";
                syntax = "<nick> <newname>";
+               TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
        }
        
        CmdResult Handle(const char** parameters, int pcnt, userrec *user)
@@ -37,7 +36,19 @@ class cmd_chgname : public command_t
                        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)