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