]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chghost.cpp
Added version flags
[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 #include <stdio.h>
18 #include <string>
19 #include "users.h"
20 #include "channels.h"
21 #include "modules.h"
22
23 /* $ModDesc: Provides support for the CHGHOST command */
24
25 Server *Srv;
26          
27 void handle_chghost(char **parameters, int pcnt, userrec *user)
28 {
29         for (int x = 0; x < strlen(parameters[1]); x++)
30         {
31                 if (((tolower(parameters[1][x]) < 'a') || (tolower(parameters[1][x]) > 'z')) && (parameters[1][x] != '.'))
32                 {
33                         if (((parameters[1][x] < '0') || (parameters[1][x]> '9')) && (parameters[1][x] != '-'))
34                         {
35                                 Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
36                                 return;
37                         }
38                 }
39         }       userrec* dest = Srv->FindNick(std::string(parameters[0]));
40         if (dest)
41         {
42                 Srv->ChangeHost(dest,parameters[1]);
43                 Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1]));
44         }
45 }
46
47
48 class ModuleChgHost : public Module
49 {
50  public:
51         ModuleChgHost()
52         {
53                 Srv = new Server;
54                 Srv->AddCommand("CHGHOST",handle_chghost,'o',2,"m_chghost.so");
55         }
56         
57         virtual ~ModuleChgHost()
58         {
59                 delete Srv;
60         }
61         
62         virtual Version GetVersion()
63         {
64                 return Version(1,0,0,0,0);
65         }
66         
67 };
68
69 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
70
71 class ModuleChgHostFactory : public ModuleFactory
72 {
73  public:
74         ModuleChgHostFactory()
75         {
76         }
77         
78         ~ModuleChgHostFactory()
79         {
80         }
81         
82         virtual Module * CreateModule()
83         {
84                 return new ModuleChgHost;
85         }
86         
87 };
88
89
90 extern "C" void * init_module( void )
91 {
92         return new ModuleChgHostFactory;
93 }
94