]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chgident.cpp
3ab558b5741ea1bdd3f4092088ea1dd9ce9da452
[user/henk/code/inspircd.git] / src / modules / m_chgident.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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
16 /* $ModDesc: Provides support for the CHGIDENT command */
17
18 /** Handle /CHGIDENT
19  */
20 class CommandChgident : public Command
21 {
22  public:
23         CommandChgident (InspIRCd* Instance) : Command(Instance,"CHGIDENT", "o", 2)
24         {
25                 this->source = "m_chgident.so";
26                 syntax = "<nick> <newident>";
27                 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
28         }
29         
30         CmdResult Handle(const std::vector<std::string> &parameters, User *user)
31         {
32                 User* dest = ServerInstance->FindNick(parameters[0]);
33
34                 if (!dest)
35                 {
36                         user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
37                         return CMD_FAILURE;
38                 }
39
40                 if (parameters[1].empty())
41                 {
42                         user->WriteServ("NOTICE %s :*** CHGIDENT: Ident must be specified", user->nick.c_str());
43                         return CMD_FAILURE;
44                 }
45                 
46                 if (parameters[1].length() > ServerInstance->Config->Limits.IdentMax)
47                 {
48                         user->WriteServ("NOTICE %s :*** CHGIDENT: Ident is too long", user->nick.c_str());
49                         return CMD_FAILURE;
50                 }
51                 
52                 if (!ServerInstance->IsIdent(parameters[1].c_str()))
53                 {
54                         user->WriteServ("NOTICE %s :*** CHGIDENT: Invalid characters in ident", user->nick.c_str());
55                         return CMD_FAILURE;
56                 }
57
58                 dest->ChangeIdent(parameters[1].c_str());
59
60                 if (!ServerInstance->ULine(user->server))
61                         ServerInstance->SNO->WriteToSnoMask('A', "%s used CHGIDENT to change %s's ident to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str());
62
63                 /* route it! */
64                 return CMD_SUCCESS;
65         }
66 };
67
68
69 class ModuleChgIdent : public Module
70 {
71         CommandChgident* mycommand;
72         
73         
74 public:
75         ModuleChgIdent(InspIRCd* Me) : Module(Me)
76         {
77                 mycommand = new CommandChgident(ServerInstance);
78                 ServerInstance->AddCommand(mycommand);
79
80         }
81         
82         virtual ~ModuleChgIdent()
83         {
84         }
85         
86         virtual Version GetVersion()
87         {
88                 return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
89         }
90         
91 };
92
93 MODULE_INIT(ModuleChgIdent)
94