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"
27 /* $ModDesc: Provides support for the CHGHOST command */
30 extern InspIRCd* ServerInstance;
32 class cmd_chghost : public command_t
35 cmd_chghost () : command_t("CHGHOST",'o',2)
37 this->source = "m_chghost.so";
38 syntax = "<nick> <newhost>";
41 void Handle(const char** parameters, int pcnt, userrec *user)
43 const char * x = parameters[1];
47 if (((tolower(*x) < 'a') || (tolower(*x) > 'z')) && (*x != '.'))
49 if (((*x < '0') || (*x > '9')) && (*x != '-'))
51 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
56 if ((parameters[1] - x) > 63)
58 user->WriteServ("NOTICE %s :*** CHGHOST: Host too long",user->nick);
61 userrec* dest = ServerInstance->FindNick(parameters[0]);
64 if ((dest->ChangeDisplayedHost(parameters[1])) && (!Srv->IsUlined(user->server)))
66 // fix by brain - ulines set hosts silently
67 ServerInstance->WriteOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+dest->nick+" become "+parameters[1]);
74 class ModuleChgHost : public Module
76 cmd_chghost* mycommand;
78 ModuleChgHost(Server* Me)
82 mycommand = new cmd_chghost();
83 Srv->AddCommand(mycommand);
86 void Implements(char* List)
90 virtual ~ModuleChgHost()
94 virtual Version GetVersion()
96 return Version(1,2,0,1,VF_VENDOR);
101 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
103 class ModuleChgHostFactory : public ModuleFactory
106 ModuleChgHostFactory()
110 ~ModuleChgHostFactory()
114 virtual Module * CreateModule(Server* Me)
116 return new ModuleChgHost(Me);
122 extern "C" void * init_module( void )
124 return new ModuleChgHostFactory;