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