1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
22 /* $ModDesc: Provides support for the CHGHOST command */
26 class cmd_chghost : public command_t
29 cmd_chghost (InspIRCd* Instance) : command_t(Instance,"CHGHOST",'o',2)
31 this->source = "m_chghost.so";
32 syntax = "<nick> <newhost>";
35 CmdResult Handle(const char** parameters, int pcnt, userrec *user)
37 const char * x = parameters[1];
41 if (((tolower(*x) < 'a') || (tolower(*x) > 'z')) && (*x != '.'))
43 if (((*x < '0') || (*x > '9')) && (*x != '-'))
45 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
50 if ((parameters[1] - x) > 63)
52 user->WriteServ("NOTICE %s :*** CHGHOST: Host too long",user->nick);
55 userrec* dest = ServerInstance->FindNick(parameters[0]);
58 if ((dest->ChangeDisplayedHost(parameters[1])) && (!ServerInstance->ULine(user->server)))
60 // fix by brain - ulines set hosts silently
61 ServerInstance->WriteOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->dhost);
71 class ModuleChgHost : public Module
73 cmd_chghost* mycommand;
75 ModuleChgHost(InspIRCd* Me)
79 mycommand = new cmd_chghost(ServerInstance);
80 ServerInstance->AddCommand(mycommand);
83 void Implements(char* List)
87 virtual ~ModuleChgHost()
91 virtual Version GetVersion()
93 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
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(InspIRCd* Me)
113 return new ModuleChgHost(Me);
119 extern "C" void * init_module( void )
121 return new ModuleChgHostFactory;