]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_gline.cpp
Remove a TODO comment. Also added support for <database:port> option since r6213...
[user/henk/code/inspircd.git] / src / cmd_gline.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 "configreader.h"
15 #include "users.h"
16 #include "modules.h"
17 #include "xline.h"
18 #include "commands/cmd_gline.h"
19
20 extern "C" command_t* init_command(InspIRCd* Instance)
21 {
22         return new cmd_gline(Instance);
23 }
24
25 /** Handle /GLINE
26  */
27 CmdResult cmd_gline::Handle (const char** parameters, int pcnt, userrec *user)
28 {
29         if (pcnt >= 3)
30         {
31                 if (ServerInstance->HostMatchesEveryone(parameters[0],user))
32                         return CMD_FAILURE;
33
34                 if (!strchr(parameters[0],'@'))
35                 {       
36                         user->WriteServ("NOTICE %s :*** G-Line must contain a username, e.g. *@%s",user->nick,parameters[0]);
37                         return CMD_FAILURE;
38                 }
39
40                 if (ServerInstance->XLines->add_gline(ServerInstance->Duration(parameters[1]),user->nick,parameters[2],parameters[0]))
41                 {
42                         FOREACH_MOD(I_OnAddGLine,OnAddGLine(ServerInstance->Duration(parameters[1]), user, parameters[2], parameters[0]));
43
44                         if (!ServerInstance->Duration(parameters[1]))
45                         {
46                                 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent G-line for %s.",user->nick,parameters[0]);
47                         }
48                         else
49                         {
50                                 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires in %d seconds.",user->nick,parameters[0],ServerInstance->Duration(parameters[1]));
51                         }
52
53                         ServerInstance->XLines->apply_lines(APPLY_GLINES);
54                 }
55                 else
56                 {
57                         user->WriteServ("NOTICE %s :*** G-Line for %s already exists",user->nick,parameters[0]);
58                 }
59
60         }
61         else
62         {
63                 if (ServerInstance->XLines->del_gline(parameters[0]))
64                 {
65                         FOREACH_MOD(I_OnDelGLine,OnDelGLine(user, parameters[0]));
66                         ServerInstance->SNO->WriteToSnoMask('x',"%s Removed G-line on %s.",user->nick,parameters[0]);
67                 }
68                 else
69                 {
70                         user->WriteServ("NOTICE %s :*** G-line %s not found in list, try /stats g.",user->nick,parameters[0]);
71                 }
72         }
73
74         return CMD_SUCCESS;
75 }
76