]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chgident.cpp
More factory conversion
[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 "inspircd.h"
15 #include "users.h"
16 #include "modules.h"
17
18 /* $ModDesc: Provides support for the CHGIDENT command */
19
20 /** Handle /CHGIDENT
21  */
22 class cmd_chgident : public command_t
23 {
24  public:
25         cmd_chgident (InspIRCd* Instance) : command_t(Instance,"CHGIDENT", 'o', 2)
26         {
27                 this->source = "m_chgident.so";
28                 syntax = "<nick> <newident>";
29         }
30         
31         CmdResult Handle(const char** parameters, int pcnt, userrec *user)
32         {
33                 userrec* dest = ServerInstance->FindNick(parameters[0]);
34
35                 if (!dest)
36                 {
37                         user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]);
38                         return CMD_FAILURE;
39                 }
40
41                 if(!ServerInstance->IsIdent(parameters[1]))
42                 {
43                         user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick);
44                         return CMD_FAILURE;
45                 }
46
47                 dest->ChangeIdent(parameters[1]);
48                 ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident to '%s'", user->nick, dest->nick, dest->ident);
49
50                 /* route it! */
51                 return CMD_SUCCESS;
52         }
53 };
54
55
56 class ModuleChgIdent : public Module
57 {
58         cmd_chgident* mycommand;
59         
60         
61 public:
62         ModuleChgIdent(InspIRCd* Me) : Module(Me)
63         {
64                 mycommand = new cmd_chgident(ServerInstance);
65                 ServerInstance->AddCommand(mycommand);
66         }
67         
68         virtual ~ModuleChgIdent()
69         {
70         }
71         
72         virtual Version GetVersion()
73         {
74                 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
75         }
76         
77 };
78
79 MODULE_INIT(ModuleChgIdent);
80