]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chgident.cpp
391f4b20bcc25447da135f493d66f98e38d20ec6
[user/henk/code/inspircd.git] / src / modules / m_chgident.cpp
1 #include <string>
2 #include "users.h"
3 #include "modules.h"
4 #include "message.h"
5 #include "helperfuncs.h"
6 #include "inspircd.h"
7
8 /* $ModDesc: Provides support for the CHGIDENT command */
9
10 extern InspIRCd* ServerInstance;
11
12 class cmd_chgident : public command_t
13 {
14         Server* Srv;
15  public:
16         cmd_chgident(Server* serv) : command_t("CHGIDENT", 'o', 2)
17         {
18                 this->source = "m_chgident.so";
19                 Srv = serv;
20                 syntax = "<nick> <newident>";
21         }
22         
23         void Handle(const char** parameters, int pcnt, userrec *user)
24         {
25                 userrec* dest = ServerInstance->FindNick(parameters[0]);
26
27                 if(dest)
28                 {
29                         if(!isident(parameters[1]))
30                         {
31                                 user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick);
32                                 return;
33                         }
34                 
35                         ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident from '%s' to '%s'", user->nick, dest->nick, dest->ident, parameters[1]);
36                         strlcpy(dest->ident, parameters[1], IDENTMAX+2);
37                 }
38                 else
39                 {
40                         user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]);
41                 }
42         }
43 };
44
45
46 class ModuleChgIdent : public Module
47 {
48         cmd_chgident* mycommand;
49         
50 public:
51         ModuleChgIdent(Server* Me) : Module::Module(Me)
52         {
53                 mycommand = new cmd_chgident(Me);
54                 Me->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(Server* 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