]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chgident.cpp
Dont echo the JOIN to the user whos speaking
[user/henk/code/inspircd.git] / src / modules / m_chgident.cpp
index 740eeadf144e0e1933af8677f39902bdcaa48ba9..42a4ef747ba35319a0e9bcb5a962e90ea6427e3a 100644 (file)
  */
 
 #include "inspircd.h"
-#include "users.h"
-#include "modules.h"
 
 /* $ModDesc: Provides support for the CHGIDENT command */
 
 /** Handle /CHGIDENT
  */
-class cmd_chgident : public command_t
+class CommandChgident : public Command
 {
  public:
-       cmd_chgident (InspIRCd* Instance) : command_t(Instance,"CHGIDENT", 'o', 2)
+       CommandChgident (InspIRCd* Instance) : Command(Instance,"CHGIDENT", 'o', 2)
        {
                this->source = "m_chgident.so";
                syntax = "<nick> <newident>";
+               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)
                {
@@ -38,14 +37,28 @@ class cmd_chgident : public command_t
                        return CMD_FAILURE;
                }
 
-               if(!ServerInstance->IsIdent(parameters[1]))
+               if (!*parameters[1])
                {
-                       user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick);
+                       user->WriteServ("NOTICE %s :*** CHGIDENT: Ident must be specified", user->nick);
+                       return CMD_FAILURE;
+               }
+               
+               if (strlen(parameters[1]) > IDENTMAX - 1)
+               {
+                       user->WriteServ("NOTICE %s :*** CHGIDENT: Ident is too long", user->nick);
+                       return CMD_FAILURE;
+               }
+               
+               if (!ServerInstance->IsIdent(parameters[1]))
+               {
+                       user->WriteServ("NOTICE %s :*** CHGIDENT: Invalid characters in ident", user->nick);
                        return CMD_FAILURE;
                }
 
                dest->ChangeIdent(parameters[1]);
-               ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident to '%s'", user->nick, dest->nick, dest->ident);
+
+               if (!ServerInstance->ULine(user->server))
+                       ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident to '%s'", user->nick, dest->nick, dest->ident);
 
                /* route it! */
                return CMD_SUCCESS;
@@ -55,13 +68,13 @@ class cmd_chgident : public command_t
 
 class ModuleChgIdent : public Module
 {
-       cmd_chgident* mycommand;
+       CommandChgident* mycommand;
        
        
 public:
        ModuleChgIdent(InspIRCd* Me) : Module(Me)
        {
-               mycommand = new cmd_chgident(ServerInstance);
+               mycommand = new CommandChgident(ServerInstance);
                ServerInstance->AddCommand(mycommand);
        }
        
@@ -71,34 +84,10 @@ public:
        
        virtual Version GetVersion()
        {
-               return Version(1,1,0,0,VF_VENDOR,API_VERSION);
+               return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
        }
        
 };
 
-// stuff down here is the module-factory stuff. For basic modules you can ignore this.
-
-class ModuleChgIdentFactory : public ModuleFactory
-{
- public:
-       ModuleChgIdentFactory()
-       {
-       }
-       
-       ~ModuleChgIdentFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleChgIdent(Me);
-       }
-       
-};
-
-
-extern "C" DllExport void * init_module( void )
-{
-       return new ModuleChgIdentFactory;
-}
+MODULE_INIT(ModuleChgIdent)