2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 class CommandEline : public Command
29 /** Constructor for eline.
31 CommandEline ( Module* parent) : Command(parent,"ELINE",1,3) { flags_needed = 'o'; syntax = "<ident@host> [<duration> :<reason>]"; }
33 * @param parameters The parameters to the command
34 * @param user The user issuing the command
35 * @return A value from CmdResult to indicate command success or failure.
37 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
42 CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User *user)
44 std::string target = parameters[0];
46 if (parameters.size() >= 3)
49 User* find = ServerInstance->FindNick(target);
50 if ((find) && (find->registered == REG_ALL))
53 ih.second = find->GetIPString();
54 target = std::string("*@") + find->GetIPString();
57 ih = ServerInstance->XLines->IdentSplit(target);
61 user->WriteNotice("*** Target not found");
65 if (ServerInstance->HostMatchesEveryone(ih.first+"@"+ih.second,user))
68 unsigned long duration = InspIRCd::Duration(parameters[1]);
69 ELine* el = new ELine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ih.first.c_str(), ih.second.c_str());
70 if (ServerInstance->XLines->AddLine(el, user))
74 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent E-line for %s: %s", user->nick.c_str(), target.c_str(), parameters[2].c_str());
78 time_t c_requires_crap = duration + ServerInstance->Time();
79 std::string timestr = InspIRCd::TimeString(c_requires_crap);
80 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed E-line for %s, expires on %s: %s",user->nick.c_str(),target.c_str(),
81 timestr.c_str(), parameters[2].c_str());
87 user->WriteNotice("*** E-Line for " + target + " already exists");
92 if (ServerInstance->XLines->DelLine(target.c_str(), "E", user))
94 ServerInstance->SNO->WriteToSnoMask('x',"%s removed E-line on %s",user->nick.c_str(),target.c_str());
98 user->WriteNotice("*** E-Line " + target + " not found in list, try /stats e");
105 COMMAND_INIT(CommandEline)