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