1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
24 #include "helperfuncs.h"
26 /* $ModDesc: Provides support for the CHGHOST command */
31 class cmd_chghost : public command_t
34 cmd_chghost () : command_t("CHGHOST",'o',2)
36 this->source = "m_chghost.so";
39 void Handle(char **parameters, int pcnt, userrec *user)
41 if (strlen(parameters[1]) > 64)
43 WriteServ(user->fd,"NOTICE %s :*** CHGHOST: Host too long",user->nick);
46 for (unsigned int x = 0; x < strlen(parameters[1]); x++)
48 if (((tolower(parameters[1][x]) < 'a') || (tolower(parameters[1][x]) > 'z')) && (parameters[1][x] != '.'))
50 if (((parameters[1][x] < '0') || (parameters[1][x]> '9')) && (parameters[1][x] != '-'))
52 Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
57 userrec* dest = Srv->FindNick(std::string(parameters[0]));
60 Srv->ChangeHost(dest,parameters[1]);
61 if (!Srv->IsUlined(user->server))
63 // fix by brain - ulines set hosts silently
64 Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1]));
71 class ModuleChgHost : public Module
73 cmd_chghost* mycommand;
75 ModuleChgHost(Server* Me)
79 mycommand = new cmd_chghost();
80 Srv->AddCommand(mycommand);
83 void Implements(char* List)
87 virtual ~ModuleChgHost()
91 virtual Version GetVersion()
93 return Version(1,2,0,1,VF_VENDOR);
98 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
100 class ModuleChgHostFactory : public ModuleFactory
103 ModuleChgHostFactory()
107 ~ModuleChgHostFactory()
111 virtual Module * CreateModule(Server* Me)
113 return new ModuleChgHost(Me);
119 extern "C" void * init_module( void )
121 return new ModuleChgHostFactory;