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

m_setident.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 
00016 /* $ModDesc: Provides support for the SETIDENT command */
00017 
00020 class CommandSetident : public Command
00021 {
00022  public:
00023  CommandSetident (InspIRCd* Instance) : Command(Instance,"SETIDENT", "o", 1)
00024         {
00025                 this->source = "m_setident.so";
00026                 syntax = "<new-ident>";
00027                 TRANSLATE2(TR_TEXT, TR_END);
00028         }
00029 
00030         CmdResult Handle(const std::vector<std::string>& parameters, User *user)
00031         {
00032                 if (parameters.size() == 0)
00033                 {
00034                         user->WriteServ("NOTICE %s :*** SETIDENT: Ident must be specified", user->nick.c_str());
00035                         return CMD_FAILURE;
00036                 }
00037 
00038                 if (parameters[0].size() > ServerInstance->Config->Limits.IdentMax)
00039                 {
00040                         user->WriteServ("NOTICE %s :*** SETIDENT: Ident is too long", user->nick.c_str());
00041                         return CMD_FAILURE;
00042                 }
00043 
00044                 if (!ServerInstance->IsIdent(parameters[0].c_str()))
00045                 {
00046                         user->WriteServ("NOTICE %s :*** SETIDENT: Invalid characters in ident", user->nick.c_str());
00047                         return CMD_FAILURE;
00048                 }
00049 
00050                 user->ChangeIdent(parameters[0].c_str());
00051                 ServerInstance->SNO->WriteToSnoMask('A', "%s used SETIDENT to change their ident to '%s'", user->nick.c_str(), user->ident.c_str());
00052 
00053                 return CMD_SUCCESS;
00054         }
00055 };
00056 
00057 
00058 class ModuleSetIdent : public Module
00059 {
00060         CommandSetident*        mycommand;
00061 
00062  public:
00063         ModuleSetIdent(InspIRCd* Me) : Module(Me)
00064         {
00065 
00066                 mycommand = new CommandSetident(ServerInstance);
00067                 ServerInstance->AddCommand(mycommand);
00068 
00069         }
00070 
00071         virtual ~ModuleSetIdent()
00072         {
00073         }
00074 
00075         virtual Version GetVersion()
00076         {
00077                 return Version("$Id: m_setident.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_COMMON | VF_VENDOR, API_VERSION);
00078         }
00079 
00080 };
00081 
00082 
00083 MODULE_INIT(ModuleSetIdent)