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