]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chgident.cpp
43bb34b319b3a9f2e1234dc1cba4f05b83fdf906
[user/henk/code/inspircd.git] / src / modules / m_chgident.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include <string>
15 #include "users.h"
16 #include "modules.h"
17 #include "inspircd.h"
18
19 /* $ModDesc: Provides support for the CHGIDENT command */
20
21 /** Handle /CHGIDENT
22  */
23 class cmd_chgident : public command_t
24 {
25  public:
26         cmd_chgident (InspIRCd* Instance) : command_t(Instance,"CHGIDENT", 'o', 2)
27         {
28                 this->source = "m_chgident.so";
29                 syntax = "<nick> <newident>";
30         }
31         
32         CmdResult Handle(const char** parameters, int pcnt, userrec *user)
33         {
34                 userrec* dest = ServerInstance->FindNick(parameters[0]);
35
36                 if (!dest)
37                 {
38                         user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]);
39                         return CMD_FAILURE;
40                 }
41
42                 if(!ServerInstance->IsIdent(parameters[1]))
43                 {
44                         user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick);
45                         return CMD_FAILURE;
46                 }
47
48                 dest->ChangeIdent(parameters[1]);
49                 ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident to '%s'", user->nick, dest->nick, dest->ident);
50
51                 /* route it! */
52                 return CMD_SUCCESS;
53         }
54 };
55
56
57 class ModuleChgIdent : public Module
58 {
59         cmd_chgident* mycommand;
60         
61         
62 public:
63         ModuleChgIdent(InspIRCd* Me) : Module::Module(Me)
64         {
65                 mycommand = new cmd_chgident(ServerInstance);
66                 ServerInstance->AddCommand(mycommand);
67         }
68         
69         virtual ~ModuleChgIdent()
70         {
71         }
72         
73         virtual Version GetVersion()
74         {
75                 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
76         }
77         
78 };
79
80 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
81
82 class ModuleChgIdentFactory : public ModuleFactory
83 {
84  public:
85         ModuleChgIdentFactory()
86         {
87         }
88         
89         ~ModuleChgIdentFactory()
90         {
91         }
92         
93         virtual Module * CreateModule(InspIRCd* Me)
94         {
95                 return new ModuleChgIdent(Me);
96         }
97         
98 };
99
100
101 extern "C" void * init_module( void )
102 {
103         return new ModuleChgIdentFactory;
104 }
105