]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chgident.cpp
1c9e3f6f4e843492937db02bbfbaa7acc95b303e
[user/henk/code/inspircd.git] / src / modules / m_chgident.cpp
1 #include <string>
2 #include "users.h"
3 #include "modules.h"
4
5 #include "inspircd.h"
6
7 /* $ModDesc: Provides support for the CHGIDENT command */
8
9
10
11 class cmd_chgident : public command_t
12 {
13  public:
14         cmd_chgident (InspIRCd* Instance) : command_t(Instance,"CHGIDENT", 'o', 2)
15         {
16                 this->source = "m_chgident.so";
17                 syntax = "<nick> <newident>";
18         }
19         
20         CmdResult Handle(const char** parameters, int pcnt, userrec *user)
21         {
22                 userrec* dest = ServerInstance->FindNick(parameters[0]);
23
24                 if(dest)
25                 {
26                         if(!ServerInstance->IsIdent(parameters[1]))
27                         {
28                                 user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick);
29                                 return CMD_FAILURE;
30                         }
31                 
32                         ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident from '%s' to '%s'", user->nick, dest->nick, dest->ident, parameters[1]);
33                         dest->ChangeIdent(parameters[1]);
34                         return CMD_SUCCESS;
35                 }
36                 else
37                 {
38                         user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]);
39                         return CMD_FAILURE;
40                 }
41         }
42 };
43
44
45 class ModuleChgIdent : public Module
46 {
47         cmd_chgident* mycommand;
48         
49         
50 public:
51         ModuleChgIdent(InspIRCd* Me) : Module::Module(Me)
52         {
53                 mycommand = new cmd_chgident(ServerInstance);
54                 ServerInstance->AddCommand(mycommand);
55         }
56         
57         virtual ~ModuleChgIdent()
58         {
59         }
60         
61         virtual Version GetVersion()
62         {
63                 return Version(1,0,0,0,VF_VENDOR);
64         }
65         
66 };
67
68 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
69
70 class ModuleChgIdentFactory : public ModuleFactory
71 {
72  public:
73         ModuleChgIdentFactory()
74         {
75         }
76         
77         ~ModuleChgIdentFactory()
78         {
79         }
80         
81         virtual Module * CreateModule(InspIRCd* Me)
82         {
83                 return new ModuleChgIdent(Me);
84         }
85         
86 };
87
88
89 extern "C" void * init_module( void )
90 {
91         return new ModuleChgIdentFactory;
92 }
93