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 CHGHOST command */
31 class cmd_chghost : public command_t
34 cmd_chghost (InspIRCd* Instance) : command_t(Instance,"CHGHOST",'o',2)
36 this->source = "m_chghost.so";
37 syntax = "<nick> <newhost>";
40 CmdResult Handle(const char** parameters, int pcnt, userrec *user)
42 const char * x = parameters[1];
46 if (((tolower(*x) < 'a') || (tolower(*x) > 'z')) && (*x != '.'))
48 if (((*x < '0') || (*x > '9')) && (*x != '-'))
50 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
55 if ((parameters[1] - x) > 63)
57 user->WriteServ("NOTICE %s :*** CHGHOST: Host too long",user->nick);
60 userrec* dest = ServerInstance->FindNick(parameters[0]);
63 if ((dest->ChangeDisplayedHost(parameters[1])) && (!ServerInstance->ULine(user->server)))
65 // fix by brain - ulines set hosts silently
66 ServerInstance->WriteOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->dhost);
76 class ModuleChgHost : public Module
78 cmd_chghost* mycommand;
80 ModuleChgHost(InspIRCd* Me)
84 mycommand = new cmd_chghost(ServerInstance);
85 ServerInstance->AddCommand(mycommand);
88 void Implements(char* List)
92 virtual ~ModuleChgHost()
96 virtual Version GetVersion()
98 return Version(1,2,0,1,VF_VENDOR);
103 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
105 class ModuleChgHostFactory : public ModuleFactory
108 ModuleChgHostFactory()
112 ~ModuleChgHostFactory()
116 virtual Module * CreateModule(InspIRCd* Me)
118 return new ModuleChgHost(Me);
124 extern "C" void * init_module( void )
126 return new ModuleChgHostFactory;