1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 #include "commands/cmd_gline.h"
18 extern "C" DllExport Command* init_command(InspIRCd* Instance)
20 return new CommandGline(Instance);
25 CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User *user)
27 std::string target = parameters[0];
29 if (parameters.size() >= 3)
32 User* find = ServerInstance->FindNick(target.c_str());
36 ih.second = find->GetIPString();
37 target = std::string("*@") + find->GetIPString();
40 ih = ServerInstance->XLines->IdentSplit(target.c_str());
44 user->WriteServ("NOTICE %s :*** Target not found", user->nick.c_str());
48 if (ServerInstance->HostMatchesEveryone(ih.first+"@"+ih.second,user))
51 else if (target.find('!') != std::string::npos)
53 user->WriteServ("NOTICE %s :*** G-Line cannot operate on nick!user@host masks",user->nick.c_str());
57 long duration = ServerInstance->Duration(parameters[1].c_str());
58 GLine* gl = new GLine(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ih.first.c_str(), ih.second.c_str());
59 if (ServerInstance->XLines->AddLine(gl, user))
63 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent G-line for %s.",user->nick.c_str(),target.c_str());
67 time_t c_requires_crap = duration + ServerInstance->Time();
68 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires on %s",user->nick.c_str(),target.c_str(),
69 ServerInstance->TimeString(c_requires_crap).c_str());
72 ServerInstance->XLines->ApplyLines();
77 user->WriteServ("NOTICE %s :*** G-Line for %s already exists",user->nick.c_str(),target.c_str());
83 if (ServerInstance->XLines->DelLine(target.c_str(),"G",user))
85 ServerInstance->SNO->WriteToSnoMask('x',"%s Removed G-line on %s.",user->nick.c_str(),target.c_str());
89 user->WriteServ("NOTICE %s :*** G-line %s not found in list, try /stats g.",user->nick.c_str(),target.c_str());