]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_qline.cpp
Header update: 2007 -> 2008
[user/henk/code/inspircd.git] / src / commands / cmd_qline.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 #include "xline.h"
16 #include "commands/cmd_qline.h"
17
18
19
20 extern "C" DllExport Command* init_command(InspIRCd* Instance)
21 {
22         return new CommandQline(Instance);
23 }
24
25 CmdResult CommandQline::Handle (const char** parameters, int pcnt, User *user)
26 {
27         if (pcnt >= 3)
28         {
29                 if (ServerInstance->NickMatchesEveryone(parameters[0],user))
30                         return CMD_FAILURE;
31
32                 if (strchr(parameters[0],'@') || strchr(parameters[0],'!') || strchr(parameters[0],'.'))
33                 {
34                         user->WriteServ("NOTICE %s :*** A Q-Line only bans a nick pattern, not a nick!user@host pattern.",user->nick);
35                         return CMD_FAILURE;
36                 }
37
38                 long duration = ServerInstance->Duration(parameters[1]);
39                 QLine* ql = new QLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2], parameters[0]);
40                 if (ServerInstance->XLines->AddLine(ql,user))
41                 {
42                         if (!duration)
43                         {
44                                 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Q-line for %s.",user->nick,parameters[0]);
45                         }
46                         else
47                         {
48                                 time_t c_requires_crap = duration + ServerInstance->Time();
49                                 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s",user->nick,parameters[0],
50                                           ServerInstance->TimeString(c_requires_crap).c_str());
51                         }
52                         ServerInstance->XLines->ApplyLines();
53                 }
54                 else
55                 {
56                         delete ql;
57                         user->WriteServ("NOTICE %s :*** Q-Line for %s already exists",user->nick,parameters[0]);
58                 }
59         }
60         else
61         {
62                 if (ServerInstance->XLines->DelLine(parameters[0],"Q",user))
63                 {
64                         ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Q-line on %s.",user->nick,parameters[0]);
65                 }
66                 else
67                 {
68                         user->WriteServ("NOTICE %s :*** Q-Line %s not found in list, try /stats q.",user->nick,parameters[0]);
69                         return CMD_FAILURE;
70                 }
71         }
72
73         return CMD_SUCCESS;
74 }
75