]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setident.cpp
Remove unnecessary header traffic
[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_t
21 {
22  public:
23  cmd_setident (InspIRCd* Instance) : command_t(Instance,"SETIDENT", 'o', 1)
24         {
25                 this->source = "m_setident.so";
26                 syntax = "<new-ident>";
27         }
28
29         CmdResult Handle(const char** parameters, int pcnt, userrec *user)
30         {
31                 if (!*parameters[0])
32                 {
33                         user->WriteServ("NOTICE %s :*** SETIDENT: Ident must be specified", user->nick);
34                         return CMD_FAILURE;
35                 }
36                 
37                 if (strlen(parameters[0]) > IDENTMAX)
38                 {
39                         user->WriteServ("NOTICE %s :*** SETIDENT: Ident is too long", user->nick);
40                         return CMD_FAILURE;
41                 }
42                 
43                 if (!ServerInstance->IsIdent(parameters[0]))
44                 {
45                         user->WriteServ("NOTICE %s :*** SETIDENT: Invalid characters in ident", user->nick);
46                         return CMD_FAILURE;
47                 }
48                 
49                 user->ChangeIdent(parameters[0]);
50                 ServerInstance->WriteOpers("%s used SETIDENT to change their ident to '%s'", user->nick, user->ident);
51
52                 return CMD_SUCCESS;
53         }
54 };
55
56
57 class ModuleSetIdent : public Module
58 {
59         cmd_setident*   mycommand;
60         
61  public:
62         ModuleSetIdent(InspIRCd* Me) : Module(Me)
63         {
64                 
65                 mycommand = new cmd_setident(ServerInstance);
66                 ServerInstance->AddCommand(mycommand);
67         }
68         
69         virtual ~ModuleSetIdent()
70         {
71         }
72         
73         virtual Version GetVersion()
74         {
75                 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
76         }
77         
78 };
79
80
81 MODULE_INIT(ModuleSetIdent)