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