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