]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setident.cpp
WHEEEEE!!!!!
[user/henk/code/inspircd.git] / src / modules / m_setident.cpp
1 #include "users.h"
2 #include "modules.h"
3 #include "helperfuncs.h"
4
5 /* $ModDesc: Provides support for the SETIDENT command */
6
7 static Server *Srv;
8
9 class cmd_setident : public command_t
10 {
11  public:
12         cmd_setident() : command_t("SETIDENT", 'o', 1)
13         {
14                 this->source = "m_setident.so";
15                 syntax = "<new-ident>";
16         }
17
18         void Handle(const char** parameters, int pcnt, userrec *user)
19         {
20                 for(unsigned int x = 0; x < strlen(parameters[0]); x++)
21                 {
22                         if(((parameters[0][x] >= 'A') && (parameters[0][x] <= '}')) || strchr(".-0123456789", parameters[0][x]))
23                                 continue;
24                         
25                         user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick);
26                         return;
27                 }
28                 
29                 WriteOpers("%s used SETIDENT to change their ident from '%s' to '%s'", user->nick, user->ident, parameters[0]);
30                 strlcpy(user->ident, parameters[0], IDENTMAX+2);
31         }
32 };
33
34
35 class ModuleSetIdent : public Module
36 {
37         cmd_setident*   mycommand;
38         
39  public:
40         ModuleSetIdent(Server* Me) : Module::Module(Me)
41         {
42                 Srv = Me;
43                 mycommand = new cmd_setident();
44                 Srv->AddCommand(mycommand);
45         }
46         
47         virtual ~ModuleSetIdent()
48         {
49         }
50         
51         virtual Version GetVersion()
52         {
53                 return Version(1,0,0,0,VF_VENDOR);
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(Server* 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