]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sethost.cpp
Added new modules m_chghost, m_sethost, m_setname
[user/henk/code/inspircd.git] / src / modules / m_sethost.cpp
1 /*
2  *  SETHOST module for InspIRCD
3  *  Author: brain
4  *  Version: 1.0.0.0
5  *
6  *  Syntax: /SETHOST [new host]
7  *  Changes the user's DHOST who issues the command
8  *  (oper only)
9  *  
10  */
11
12 #include <stdio.h>
13 #include <string>
14 #include "users.h"
15 #include "channels.h"
16 #include "modules.h"
17
18 /* $ModDesc: Provides support for the SETHOST command */
19
20 Server *Srv;
21          
22 void handle_sethost(char **parameters, int pcnt, userrec *user)
23 {
24         strncpy(user->dhost,parameters[0],127);
25         Srv->SendOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+std::string(parameters[1]));
26 }
27
28
29 class ModuleSetHost : public Module
30 {
31  public:
32         ModuleSetHost()
33         {
34                 Srv = new Server;
35                 Srv->AddCommand("SETHOST",handle_sethost,'o',1);
36         }
37         
38         virtual ~ModuleSetHost()
39         {
40                 delete Srv;
41         }
42         
43         virtual Version GetVersion()
44         {
45                 return Version(1,0,0,0);
46         }
47         
48 };
49
50 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
51
52 class ModuleSetHostFactory : public ModuleFactory
53 {
54  public:
55         ModuleSetHostFactory()
56         {
57         }
58         
59         ~ModuleSetHostFactory()
60         {
61         }
62         
63         virtual Module * CreateModule()
64         {
65                 return new ModuleSetHost;
66         }
67         
68 };
69
70
71 extern "C" void * init_module( void )
72 {
73         return new ModuleSetHostFactory;
74 }
75