]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setident.cpp
4a19b8412a54b7712ef5f3a53fd57200ce7ff686
[user/henk/code/inspircd.git] / src / modules / m_setident.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 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 cmd_setident : public Command
21 {
22  public:
23  cmd_setident (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** parameters, int pcnt, userrec *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->WriteOpers("%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         cmd_setident*   mycommand;
61         
62  public:
63         ModuleSetIdent(InspIRCd* Me) : Module(Me)
64         {
65                 
66                 mycommand = new cmd_setident(ServerInstance);
67                 ServerInstance->AddCommand(mycommand);
68         }
69         
70         virtual ~ModuleSetIdent()
71         {
72         }
73         
74         virtual Version GetVersion()
75         {
76                 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
77         }
78         
79 };
80
81
82 MODULE_INIT(ModuleSetIdent)