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 * ---------------------------------------------------
17 /** Handle /GLINE. These command handlers can be reloaded by the core,
18 * and handle basic RFC1459 commands. Commands within modules work
19 * the same way, however, they can be fully unloaded, where these
22 class CommandGline : public Command
25 /** Constructor for gline.
27 CommandGline (Module* parent) : Command(parent,"GLINE",1,3) { flags_needed = 'o'; Penalty = 0; syntax = "<ident@host> [<duration> :<reason>]"; }
29 * @param parameters The parameters to the comamnd
30 * @param pcnt The number of parameters passed to teh command
31 * @param user The user issuing the command
32 * @return A value from CmdResult to indicate command success or failure.
34 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
40 CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User *user)
42 std::string target = parameters[0];
44 if (parameters.size() >= 3)
47 User* find = ServerInstance->FindNick(target.c_str());
51 ih.second = find->GetIPString();
52 target = std::string("*@") + find->GetIPString();
55 ih = ServerInstance->XLines->IdentSplit(target.c_str());
59 user->WriteServ("NOTICE %s :*** Target not found", user->nick.c_str());
63 if (ServerInstance->HostMatchesEveryone(ih.first+"@"+ih.second,user))
66 else if (target.find('!') != std::string::npos)
68 user->WriteServ("NOTICE %s :*** G-Line cannot operate on nick!user@host masks",user->nick.c_str());
72 long duration = ServerInstance->Duration(parameters[1].c_str());
73 GLine* gl = new GLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ih.first.c_str(), ih.second.c_str());
74 if (ServerInstance->XLines->AddLine(gl, user))
78 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent G-line for %s: %s",user->nick.c_str(),target.c_str(), parameters[2].c_str());
82 time_t c_requires_crap = duration + ServerInstance->Time();
83 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires on %s: %s",user->nick.c_str(),target.c_str(),
84 ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
87 ServerInstance->XLines->ApplyLines();
92 user->WriteServ("NOTICE %s :*** G-Line for %s already exists",user->nick.c_str(),target.c_str());
98 if (ServerInstance->XLines->DelLine(target.c_str(),"G",user))
100 ServerInstance->SNO->WriteToSnoMask('x',"%s removed G-line on %s",user->nick.c_str(),target.c_str());
104 user->WriteServ("NOTICE %s :*** G-line %s not found in list, try /stats g.",user->nick.c_str(),target.c_str());
111 COMMAND_INIT(CommandGline)