]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setident.cpp
Remove InspIRCd* parameters and fields
[user/henk/code/inspircd.git] / src / modules / m_setident.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 SETIDENT command */
17
18 /** Handle /SETIDENT
19  */
20 class CommandSetident : public Command
21 {
22  public:
23  CommandSetident(Module* Creator) : Command(Creator,"SETIDENT", 1)
24         {
25                 flags_needed = 'o'; syntax = "<new-ident>";
26                 TRANSLATE2(TR_TEXT, TR_END);
27         }
28
29         CmdResult Handle(const std::vector<std::string>& parameters, User *user)
30         {
31                 if (parameters.size() == 0)
32                 {
33                         user->WriteServ("NOTICE %s :*** SETIDENT: Ident must be specified", user->nick.c_str());
34                         return CMD_FAILURE;
35                 }
36
37                 if (parameters[0].size() > ServerInstance->Config->Limits.IdentMax)
38                 {
39                         user->WriteServ("NOTICE %s :*** SETIDENT: Ident is too long", user->nick.c_str());
40                         return CMD_FAILURE;
41                 }
42
43                 if (!ServerInstance->IsIdent(parameters[0].c_str()))
44                 {
45                         user->WriteServ("NOTICE %s :*** SETIDENT: Invalid characters in ident", user->nick.c_str());
46                         return CMD_FAILURE;
47                 }
48
49                 user->ChangeIdent(parameters[0].c_str());
50                 ServerInstance->SNO->WriteGlobalSno('a', "%s used SETIDENT to change their ident to '%s'", user->nick.c_str(), user->ident.c_str());
51
52                 return CMD_SUCCESS;
53         }
54 };
55
56
57 class ModuleSetIdent : public Module
58 {
59         CommandSetident cmd;
60
61  public:
62         ModuleSetIdent() : cmd(this)
63         {
64                 ServerInstance->AddCommand(&cmd);
65         }
66
67         virtual ~ModuleSetIdent()
68         {
69         }
70
71         virtual Version GetVersion()
72         {
73                 return Version("Provides support for the SETIDENT command", VF_VENDOR, API_VERSION);
74         }
75
76 };
77
78
79 MODULE_INIT(ModuleSetIdent)