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