X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_xline%2Fcmd_qline.cpp;h=4857bf2a8dc0386ea4b70d72b9c5492a0d41ca82;hb=6b188f1d4ebd00c1e93a0a4ac68af04de0bbaeab;hp=6dc0da9bad7ec210e62fbe690a6bd39840ae9c9d;hpb=124c17e14134a4999afc1a5e981ab7c75b3694b9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_xline/cmd_qline.cpp b/src/coremods/core_xline/cmd_qline.cpp index 6dc0da9ba..4857bf2a8 100644 --- a/src/coremods/core_xline/cmd_qline.cpp +++ b/src/coremods/core_xline/cmd_qline.cpp @@ -1,9 +1,17 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2019 Matt Schatz + * Copyright (C) 2018 linuxdaemon + * Copyright (C) 2018 Sadie Powell + * Copyright (C) 2014 Attila Molnar + * Copyright (C) 2012, 2019 Robby + * Copyright (C) 2009 Uli Schlachter * Copyright (C) 2009 Daniel De Graaf - * Copyright (C) 2008 Craig Edwards + * Copyright (C) 2008 Thomas Stagner * Copyright (C) 2007 Robin Burchell + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2006-2008, 2010 Craig Edwards * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -27,10 +35,10 @@ CommandQline::CommandQline(Module* parent) : Command(parent, "QLINE", 1, 3) { flags_needed = 'o'; - syntax = " [ :]"; + syntax = " [ :]"; } -CmdResult CommandQline::Handle (const std::vector& parameters, User *user) +CmdResult CommandQline::Handle(User* user, const Params& parameters) { if (parameters.size() >= 3) { @@ -40,42 +48,48 @@ CmdResult CommandQline::Handle (const std::vector& parameters, User if (parameters[0].find('@') != std::string::npos || parameters[0].find('!') != std::string::npos || parameters[0].find('.') != std::string::npos) { - user->WriteNotice("*** A Q-Line only bans a nick pattern, not a nick!user@host pattern."); + user->WriteNotice("*** A Q-line only bans a nick pattern, not a nick!user@host pattern."); return CMD_FAILURE; } - unsigned long duration = InspIRCd::Duration(parameters[1]); + unsigned long duration; + if (!InspIRCd::Duration(parameters[1], duration)) + { + user->WriteNotice("*** Invalid duration for Q-line."); + return CMD_FAILURE; + } QLine* ql = new QLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str()); if (ServerInstance->XLines->AddLine(ql,user)) { if (!duration) { - ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Q-line for %s: %s",user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s added permanent Q-line for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str()); } else { - time_t c_requires_crap = duration + ServerInstance->Time(); - std::string timestr = InspIRCd::TimeString(c_requires_crap); - ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s: %s",user->nick.c_str(),parameters[0].c_str(), - timestr.c_str(), parameters[2].c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s added timed Q-line for %s, expires in %s (on %s): %s", + user->nick.c_str(), parameters[0].c_str(), InspIRCd::DurationString(duration).c_str(), + InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), parameters[2].c_str()); } ServerInstance->XLines->ApplyLines(); } else { delete ql; - user->WriteNotice("*** Q-Line for " + parameters[0] + " already exists"); + user->WriteNotice("*** Q-line for " + parameters[0] + " already exists."); } } else { - if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "Q", user)) + std::string reason; + + if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "Q", reason, user)) { - ServerInstance->SNO->WriteToSnoMask('x',"%s removed Q-line on %s",user->nick.c_str(),parameters[0].c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s removed Q-line on %s: %s", user->nick.c_str(), parameters[0].c_str(), reason.c_str()); } else { - user->WriteNotice("*** Q-Line " + parameters[0] + " not found in list, try /stats q."); + user->WriteNotice("*** Q-line " + parameters[0] + " not found on the list."); return CMD_FAILURE; } }