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