]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chgident.cpp
e3067fe5622d84eccc04ed2cf71e80728642b8c1
[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 (!*parameters[1])
42                 {
43                         user->WriteServ("NOTICE %s :*** CHGIDENT: Needs non-zero length ident", user->nick);
44                         return CMD_FAILURE;
45                 }
46                 if(!ServerInstance->IsIdent(parameters[1]))
47                 {
48                         user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick);
49                         return CMD_FAILURE;
50                 }
51
52                 dest->ChangeIdent(parameters[1]);
53                 ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident to '%s'", user->nick, dest->nick, dest->ident);
54
55                 /* route it! */
56                 return CMD_SUCCESS;
57         }
58 };
59
60
61 class ModuleChgIdent : public Module
62 {
63         cmd_chgident* mycommand;
64         
65         
66 public:
67         ModuleChgIdent(InspIRCd* Me) : Module(Me)
68         {
69                 mycommand = new cmd_chgident(ServerInstance);
70                 ServerInstance->AddCommand(mycommand);
71         }
72         
73         virtual ~ModuleChgIdent()
74         {
75         }
76         
77         virtual Version GetVersion()
78         {
79                 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
80         }
81         
82 };
83
84 MODULE_INIT(ModuleChgIdent);
85