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 SETHOST command */
30 class cmd_sethost : public command_t
33 cmd_sethost() : command_t("SETHOST",'o',1)
35 this->source = "m_sethost.so";
36 syntax = "<new-hostname>";
39 void Handle (const char** parameters, int pcnt, userrec *user)
41 if (strlen(parameters[0]) > 64)
43 WriteServ(user->fd,"NOTICE %s :*** SETHOST: Host too long",user->nick);
46 for (unsigned int x = 0; x < strlen(parameters[0]); x++)
48 if (((tolower(parameters[0][x]) < 'a') || (tolower(parameters[0][x]) > 'z')) && (parameters[0][x] != '.'))
50 if (((parameters[0][x] < '0') || (parameters[0][x]> '9')) && (parameters[0][x] != '-'))
52 Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
57 Srv->ChangeHost(user,parameters[0]);
58 Srv->SendOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+std::string(parameters[0]));
63 class ModuleSetHost : public Module
65 cmd_sethost* mycommand;
67 ModuleSetHost(Server* Me)
71 mycommand = new cmd_sethost();
72 Srv->AddCommand(mycommand);
75 virtual ~ModuleSetHost()
79 virtual Version GetVersion()
81 return Version(1,0,0,1,VF_VENDOR);
86 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
88 class ModuleSetHostFactory : public ModuleFactory
91 ModuleSetHostFactory()
95 ~ModuleSetHostFactory()
99 virtual Module * CreateModule(Server* Me)
101 return new ModuleSetHost(Me);
107 extern "C" void * init_module( void )
109 return new ModuleSetHostFactory;