m_chgident.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "inspircd.h"
00015
00016
00017
00020 class CommandChgident : public Command
00021 {
00022 public:
00023 CommandChgident (InspIRCd* Instance) : Command(Instance,"CHGIDENT", "o", 2)
00024 {
00025 this->source = "m_chgident.so";
00026 syntax = "<nick> <newident>";
00027 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
00028 }
00029
00030 CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
00031 {
00032 User* dest = ServerInstance->FindNick(parameters[0]);
00033
00034 if (!dest)
00035 {
00036 user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
00037 return CMD_FAILURE;
00038 }
00039
00040 if (parameters[1].empty())
00041 {
00042 user->WriteServ("NOTICE %s :*** CHGIDENT: Ident must be specified", user->nick.c_str());
00043 return CMD_FAILURE;
00044 }
00045
00046 if (parameters[1].length() > ServerInstance->Config->Limits.IdentMax)
00047 {
00048 user->WriteServ("NOTICE %s :*** CHGIDENT: Ident is too long", user->nick.c_str());
00049 return CMD_FAILURE;
00050 }
00051
00052 if (!ServerInstance->IsIdent(parameters[1].c_str()))
00053 {
00054 user->WriteServ("NOTICE %s :*** CHGIDENT: Invalid characters in ident", user->nick.c_str());
00055 return CMD_FAILURE;
00056 }
00057
00058 dest->ChangeIdent(parameters[1].c_str());
00059
00060 if (!ServerInstance->ULine(user->server))
00061 ServerInstance->SNO->WriteToSnoMask('A', "%s used CHGIDENT to change %s's ident to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str());
00062
00063
00064 return CMD_SUCCESS;
00065 }
00066 };
00067
00068
00069 class ModuleChgIdent : public Module
00070 {
00071 CommandChgident* mycommand;
00072
00073
00074 public:
00075 ModuleChgIdent(InspIRCd* Me) : Module(Me)
00076 {
00077 mycommand = new CommandChgident(ServerInstance);
00078 ServerInstance->AddCommand(mycommand);
00079
00080 }
00081
00082 virtual ~ModuleChgIdent()
00083 {
00084 }
00085
00086 virtual Version GetVersion()
00087 {
00088 return Version("$Id: m_chgident.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_COMMON | VF_VENDOR, API_VERSION);
00089 }
00090
00091 };
00092
00093 MODULE_INIT(ModuleChgIdent)
00094