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 * ---------------------------------------------------
27 /* $ModDesc: Provides support for the SETHOST command */
32 class cmd_sethost : public command_t
35 cmd_sethost (InspIRCd* Instance) : command_t(Instance,"SETHOST",'o',1)
37 this->source = "m_sethost.so";
38 syntax = "<new-hostname>";
41 void Handle (const char** parameters, int pcnt, userrec *user)
43 if (strlen(parameters[0]) > 64)
45 user->WriteServ("NOTICE %s :*** SETHOST: Host too long",user->nick);
48 for (unsigned int x = 0; x < strlen(parameters[0]); x++)
50 if (((tolower(parameters[0][x]) < 'a') || (tolower(parameters[0][x]) > 'z')) && (parameters[0][x] != '.'))
52 if (((parameters[0][x] < '0') || (parameters[0][x]> '9')) && (parameters[0][x] != '-'))
54 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
59 if (user->ChangeDisplayedHost(parameters[0]))
60 ServerInstance->WriteOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+std::string(parameters[0]));
65 class ModuleSetHost : public Module
67 cmd_sethost* mycommand;
69 ModuleSetHost(InspIRCd* Me)
73 mycommand = new cmd_sethost(ServerInstance);
74 ServerInstance->AddCommand(mycommand);
77 virtual ~ModuleSetHost()
81 virtual Version GetVersion()
83 return Version(1,0,0,1,VF_VENDOR);
88 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
90 class ModuleSetHostFactory : public ModuleFactory
93 ModuleSetHostFactory()
97 ~ModuleSetHostFactory()
101 virtual Module * CreateModule(InspIRCd* Me)
103 return new ModuleSetHost(Me);
109 extern "C" void * init_module( void )
111 return new ModuleSetHostFactory;