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