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/>.
24 /** Handle /GLINE. These command handlers can be reloaded by the core,
25 * and handle basic RFC1459 commands. Commands within modules work
26 * the same way, however, they can be fully unloaded, where these
29 class CommandGline : public Command
32 /** Constructor for gline.
34 CommandGline (Module* parent) : Command(parent,"GLINE",1,3) { flags_needed = 'o'; Penalty = 0; syntax = "<ident@host> [<duration> :<reason>]"; }
36 * @param parameters The parameters to the comamnd
37 * @param pcnt The number of parameters passed to teh command
38 * @param user The user issuing the command
39 * @return A value from CmdResult to indicate command success or failure.
41 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
47 CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User *user)
49 std::string target = parameters[0];
51 if (parameters.size() >= 3)
54 User* find = ServerInstance->FindNick(target.c_str());
58 ih.second = find->GetIPString();
59 target = std::string("*@") + find->GetIPString();
62 ih = ServerInstance->XLines->IdentSplit(target.c_str());
66 user->WriteServ("NOTICE %s :*** Target not found", user->nick.c_str());
70 if (ServerInstance->HostMatchesEveryone(ih.first+"@"+ih.second,user))
73 else if (target.find('!') != std::string::npos)
75 user->WriteServ("NOTICE %s :*** G-Line cannot operate on nick!user@host masks",user->nick.c_str());
79 long duration = ServerInstance->Duration(parameters[1].c_str());
80 GLine* gl = new GLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ih.first.c_str(), ih.second.c_str());
81 if (ServerInstance->XLines->AddLine(gl, user))
85 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent G-line for %s: %s",user->nick.c_str(),target.c_str(), parameters[2].c_str());
89 time_t c_requires_crap = duration + ServerInstance->Time();
90 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires on %s: %s",user->nick.c_str(),target.c_str(),
91 ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
94 ServerInstance->XLines->ApplyLines();
99 user->WriteServ("NOTICE %s :*** G-Line for %s already exists",user->nick.c_str(),target.c_str());
105 if (ServerInstance->XLines->DelLine(target.c_str(),"G",user))
107 ServerInstance->SNO->WriteToSnoMask('x',"%s removed G-line on %s",user->nick.c_str(),target.c_str());
111 user->WriteServ("NOTICE %s :*** G-line %s not found in list, try /stats g.",user->nick.c_str(),target.c_str());
118 COMMAND_INIT(CommandGline)