]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chghost.cpp
f786a9f301cb323b39b0229cf30ece35c17b11ed
[user/henk/code/inspircd.git] / src / modules / m_chghost.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 #include <stdio.h>
20 #include <string>
21 #include "users.h"
22 #include "channels.h"
23 #include "modules.h"
24
25 /* $ModDesc: Provides support for the CHGHOST command */
26
27 Server *Srv;
28          
29 void handle_chghost(char **parameters, int pcnt, userrec *user)
30 {
31         for (unsigned int x = 0; x < strlen(parameters[1]); x++)
32         {
33                 if (((tolower(parameters[1][x]) < 'a') || (tolower(parameters[1][x]) > 'z')) && (parameters[1][x] != '.'))
34                 {
35                         if (((parameters[1][x] < '0') || (parameters[1][x]> '9')) && (parameters[1][x] != '-'))
36                         {
37                                 Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
38                                 return;
39                         }
40                 }
41         }       userrec* dest = Srv->FindNick(std::string(parameters[0]));
42         if (dest)
43         {
44                 Srv->ChangeHost(dest,parameters[1]);
45                 Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1]));
46         }
47 }
48
49
50 class ModuleChgHost : public Module
51 {
52  public:
53         ModuleChgHost()
54         {
55                 Srv = new Server;
56                 Srv->AddCommand("CHGHOST",handle_chghost,'o',2,"m_chghost.so");
57         }
58         
59         virtual ~ModuleChgHost()
60         {
61                 delete Srv;
62         }
63         
64         virtual Version GetVersion()
65         {
66                 return Version(1,0,0,1,VF_VENDOR);
67         }
68         
69 };
70
71 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
72
73 class ModuleChgHostFactory : public ModuleFactory
74 {
75  public:
76         ModuleChgHostFactory()
77         {
78         }
79         
80         ~ModuleChgHostFactory()
81         {
82         }
83         
84         virtual Module * CreateModule()
85         {
86                 return new ModuleChgHost;
87         }
88         
89 };
90
91
92 extern "C" void * init_module( void )
93 {
94         return new ModuleChgHostFactory;
95 }
96