1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
18 class CommandQline : public Command
21 /** Constructor for qline.
23 CommandQline ( Module* parent) : Command(parent,"QLINE",1,3) { flags_needed = 'o'; Penalty = 0; syntax = "<nick> [<duration> :<reason>]"; }
25 * @param parameters The parameters to the comamnd
26 * @param pcnt The number of parameters passed to the command
27 * @param user The user issuing the command
28 * @return A value from CmdResult to indicate command success or failure.
30 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
34 CmdResult CommandQline::Handle (const std::vector<std::string>& parameters, User *user)
36 if (parameters.size() >= 3)
38 if (ServerInstance->NickMatchesEveryone(parameters[0],user))
41 if (parameters[0].find('@') != std::string::npos || parameters[0].find('!') != std::string::npos || parameters[0].find('.') != std::string::npos)
43 user->WriteServ("NOTICE %s :*** A Q-Line only bans a nick pattern, not a nick!user@host pattern.",user->nick.c_str());
47 long duration = ServerInstance->Duration(parameters[1].c_str());
48 QLine* ql = new QLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
49 if (ServerInstance->XLines->AddLine(ql,user))
53 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Q-line for %s: %s",user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
57 time_t c_requires_crap = duration + ServerInstance->Time();
58 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s: %s",user->nick.c_str(),parameters[0].c_str(),
59 ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
61 ServerInstance->XLines->ApplyLines();
66 user->WriteServ("NOTICE %s :*** Q-Line for %s already exists",user->nick.c_str(),parameters[0].c_str());
71 if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "Q", user))
73 ServerInstance->SNO->WriteToSnoMask('x',"%s removed Q-line on %s",user->nick.c_str(),parameters[0].c_str());
77 user->WriteServ("NOTICE %s :*** Q-Line %s not found in list, try /stats q.",user->nick.c_str(),parameters[0].c_str());
86 COMMAND_INIT(CommandQline)