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 */
30 class cmd_chghost : public command_t
33 cmd_chghost () : command_t("CHGHOST",'o',2)
35 this->source = "m_chghost.so";
36 syntax = "<nick> <newhost>";
39 void Handle(const char** parameters, int pcnt, userrec *user)
41 const char * x = parameters[1];
45 if (((tolower(*x) < 'a') || (tolower(*x) > 'z')) && (*x != '.'))
47 if (((*x < '0') || (*x > '9')) && (*x != '-'))
49 Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
54 if ((parameters[1] - x) > 63)
56 WriteServ(user->fd,"NOTICE %s :*** CHGHOST: Host too long",user->nick);
59 userrec* dest = Srv->FindNick(std::string(parameters[0]));
62 Srv->ChangeHost(dest,parameters[1]);
63 if (!Srv->IsUlined(user->server))
65 // fix by brain - ulines set hosts silently
66 Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1]));
73 class ModuleChgHost : public Module
75 cmd_chghost* mycommand;
77 ModuleChgHost(Server* Me)
81 mycommand = new cmd_chghost();
82 Srv->AddCommand(mycommand);
85 void Implements(char* List)
89 virtual ~ModuleChgHost()
93 virtual Version GetVersion()
95 return Version(1,2,0,1,VF_VENDOR);
100 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
102 class ModuleChgHostFactory : public ModuleFactory
105 ModuleChgHostFactory()
109 ~ModuleChgHostFactory()
113 virtual Module * CreateModule(Server* Me)
115 return new ModuleChgHost(Me);
121 extern "C" void * init_module( void )
123 return new ModuleChgHostFactory;