]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setident.cpp
Works with the m_testclient test program/suite!
[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         }
16
17         void Handle(const char** parameters, int pcnt, userrec *user)
18         {
19                 for(unsigned int x = 0; x < strlen(parameters[0]); x++)
20                 {
21                         if(((parameters[0][x] >= 'A') && (parameters[0][x] <= '}')) || strchr(".-0123456789", parameters[0][x]))
22                                 continue;
23                         
24                         WriteServ(user->fd, "NOTICE %s :*** Invalid characters in ident", user->nick);
25                         return;
26                 }
27                 
28                 WriteOpers("%s used SETIDENT to change their ident from '%s' to '%s'", user->nick, user->ident, parameters[0]);
29                 strlcpy(user->ident, parameters[0], IDENTMAX+2);
30         }
31 };
32
33
34 class ModuleSetIdent : public Module
35 {
36         cmd_setident*   mycommand;
37         
38  public:
39         ModuleSetIdent(Server* Me) : Module::Module(Me)
40         {
41                 Srv = Me;
42                 mycommand = new cmd_setident();
43                 Srv->AddCommand(mycommand);
44         }
45         
46         virtual ~ModuleSetIdent()
47         {
48         }
49         
50         virtual Version GetVersion()
51         {
52                 return Version(1,0,0,0,VF_VENDOR);
53         }
54         
55 };
56
57 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
58
59 class ModuleSetIdentFactory : public ModuleFactory
60 {
61  public:
62         ModuleSetIdentFactory()
63         {
64         }
65         
66         ~ModuleSetIdentFactory()
67         {
68         }
69         
70         virtual Module * CreateModule(Server* Me)
71         {
72                 return new ModuleSetIdent(Me);
73         }
74         
75 };
76
77
78 extern "C" void * init_module( void )
79 {
80         return new ModuleSetIdentFactory;
81 }
82