The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download | Blog | Stats
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

m_chgident.cpp

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #include "inspircd.h"
00015 #include "users.h"
00016 #include "modules.h"
00017 
00018 /* $ModDesc: Provides support for the CHGIDENT command */
00019 
00022 class cmd_chgident : public command_t
00023 {
00024  public:
00025         cmd_chgident (InspIRCd* Instance) : command_t(Instance,"CHGIDENT", 'o', 2)
00026         {
00027                 this->source = "m_chgident.so";
00028                 syntax = "<nick> <newident>";
00029         }
00030         
00031         CmdResult Handle(const char** parameters, int pcnt, userrec *user)
00032         {
00033                 userrec* dest = ServerInstance->FindNick(parameters[0]);
00034 
00035                 if (!dest)
00036                 {
00037                         user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]);
00038                         return CMD_FAILURE;
00039                 }
00040 
00041                 if (!*parameters[1])
00042                 {
00043                         user->WriteServ("NOTICE %s :*** CHGIDENT: Ident must be specified", user->nick);
00044                         return CMD_FAILURE;
00045                 }
00046                 
00047                 if (strlen(parameters[1]) > IDENTMAX - 1)
00048                 {
00049                         user->WriteServ("NOTICE %s :*** CHGIDENT: Ident is too long", user->nick);
00050                         return CMD_FAILURE;
00051                 }
00052                 
00053                 if (!ServerInstance->IsIdent(parameters[1]))
00054                 {
00055                         user->WriteServ("NOTICE %s :*** CHGIDENT: Invalid characters in ident", user->nick);
00056                         return CMD_FAILURE;
00057                 }
00058 
00059                 dest->ChangeIdent(parameters[1]);
00060 
00061                 if (!ServerInstance->ULine(user->server))
00062                         ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident to '%s'", user->nick, dest->nick, dest->ident);
00063 
00064                 /* route it! */
00065                 return CMD_SUCCESS;
00066         }
00067 };
00068 
00069 
00070 class ModuleChgIdent : public Module
00071 {
00072         cmd_chgident* mycommand;
00073         
00074         
00075 public:
00076         ModuleChgIdent(InspIRCd* Me) : Module(Me)
00077         {
00078                 mycommand = new cmd_chgident(ServerInstance);
00079                 ServerInstance->AddCommand(mycommand);
00080         }
00081         
00082         virtual ~ModuleChgIdent()
00083         {
00084         }
00085         
00086         virtual Version GetVersion()
00087         {
00088                 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
00089         }
00090         
00091 };
00092 
00093 MODULE_INIT(ModuleChgIdent)
00094