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