2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
5 * Copyright (C) 2018 linuxdaemon <linuxdaemon.irc@gmail.com>
6 * Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
7 * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
8 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
9 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
10 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
11 * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
12 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
13 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
14 * Copyright (C) 2006-2008, 2010 Craig Edwards <brain@inspircd.org>
16 * This file is part of InspIRCd. InspIRCd is free software: you can
17 * redistribute it and/or modify it under the terms of the GNU General Public
18 * License as published by the Free Software Foundation, version 2.
20 * This program is distributed in the hope that it will be useful, but WITHOUT
21 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 #include "core_xline.h"
34 CommandQline::CommandQline(Module* parent)
35 : Command(parent, "QLINE", 1, 3)
38 syntax = "<nickmask> [<duration> :<reason>]";
41 CmdResult CommandQline::Handle(User* user, const Params& parameters)
43 if (parameters.size() >= 3)
46 if (InsaneBan::MatchesEveryone(parameters[0], matcher, user, "Q", "nickmasks"))
49 if (parameters[0].find('@') != std::string::npos || parameters[0].find('!') != std::string::npos || parameters[0].find('.') != std::string::npos)
51 user->WriteNotice("*** A Q-line only bans a nick pattern, not a nick!user@host pattern.");
55 unsigned long duration;
56 if (!InspIRCd::Duration(parameters[1], duration))
58 user->WriteNotice("*** Invalid duration for Q-line.");
61 QLine* ql = new QLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
62 if (ServerInstance->XLines->AddLine(ql,user))
66 ServerInstance->SNO->WriteToSnoMask('x', "%s added permanent Q-line for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
70 ServerInstance->SNO->WriteToSnoMask('x', "%s added timed Q-line for %s, expires in %s (on %s): %s",
71 user->nick.c_str(), parameters[0].c_str(), InspIRCd::DurationString(duration).c_str(),
72 InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), parameters[2].c_str());
74 ServerInstance->XLines->ApplyLines();
79 user->WriteNotice("*** Q-line for " + parameters[0] + " already exists.");
86 if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "Q", reason, user))
88 ServerInstance->SNO->WriteToSnoMask('x', "%s removed Q-line on %s: %s", user->nick.c_str(), parameters[0].c_str(), reason.c_str());
92 user->WriteNotice("*** Q-line " + parameters[0] + " not found on the list.");
100 bool CommandQline::NickMatcher::Check(User* user, const std::string& nick) const
102 return InspIRCd::Match(user->nick, nick);