m_chgname.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 CommandChgname : public Command
00021 {
00022 public:
00023 CommandChgname (InspIRCd* Instance) : Command(Instance,"CHGNAME", "o", 2, 2)
00024 {
00025 this->source = "m_chgname.so";
00026 syntax = "<nick> <newname>";
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 :*** GECOS must be specified", user->nick.c_str());
00043 return CMD_FAILURE;
00044 }
00045
00046 if (parameters[1].length() > ServerInstance->Config->Limits.MaxGecos)
00047 {
00048 user->WriteServ("NOTICE %s :*** GECOS too long", user->nick.c_str());
00049 return CMD_FAILURE;
00050 }
00051
00052 if (IS_LOCAL(dest))
00053 {
00054 dest->ChangeName(parameters[1].c_str());
00055 ServerInstance->SNO->WriteToSnoMask('A', "%s used CHGNAME to change %s's real name to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->fullname.c_str());
00056 return CMD_LOCALONLY;
00057 }
00058
00059
00060 return CMD_SUCCESS;
00061 }
00062 };
00063
00064
00065 class ModuleChgName : public Module
00066 {
00067 CommandChgname* mycommand;
00068
00069
00070 public:
00071 ModuleChgName(InspIRCd* Me) : Module(Me)
00072 {
00073 mycommand = new CommandChgname(ServerInstance);
00074 ServerInstance->AddCommand(mycommand);
00075
00076 }
00077
00078 virtual ~ModuleChgName()
00079 {
00080 }
00081
00082 virtual Version GetVersion()
00083 {
00084 return Version("$Id: m_chgname.cpp 10718 2008-10-25 16:41:13Z w00t $", VF_COMMON | VF_VENDOR, API_VERSION);
00085 }
00086
00087 };
00088
00089 MODULE_INIT(ModuleChgName)