]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setident.cpp
5abdcb43302847abc0f078845fe1aaebb49b0e4f
[user/henk/code/inspircd.git] / src / modules / m_setident.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 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 char* const* parameters, int pcnt, User *user)
31         {
32                 if (!*parameters[0])
33                 {
34                         user->WriteServ("NOTICE %s :*** SETIDENT: Ident must be specified", user->nick);
35                         return CMD_FAILURE;
36                 }
37                 
38                 if (strlen(parameters[0]) > IDENTMAX)
39                 {
40                         user->WriteServ("NOTICE %s :*** SETIDENT: Ident is too long", user->nick);
41                         return CMD_FAILURE;
42                 }
43                 
44                 if (!ServerInstance->IsIdent(parameters[0]))
45                 {
46                         user->WriteServ("NOTICE %s :*** SETIDENT: Invalid characters in ident", user->nick);
47                         return CMD_FAILURE;
48                 }
49                 
50                 user->ChangeIdent(parameters[0]);
51                 ServerInstance->SNO->WriteToSnoMask('A', "%s used SETIDENT to change their ident to '%s'", user->nick, user->ident);
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(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
78         }
79         
80 };
81
82
83 MODULE_INIT(ModuleSetIdent)