1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 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 char** parameters, int pcnt, User *user)
30 User* find = ServerInstance->FindNick(parameters[0]);
34 ih.second = find->GetIPString();
37 ih = ServerInstance->XLines->IdentSplit(parameters[0]);
39 if (ServerInstance->HostMatchesEveryone(ih.first+"@"+ih.second,user))
42 if (!strchr(parameters[0],'@'))
44 user->WriteServ("NOTICE %s :*** G-Line must contain a username, e.g. *@%s",user->nick,parameters[0]);
47 else if (strchr(parameters[0],'!'))
49 user->WriteServ("NOTICE %s :*** G-Line cannot contain a nickname!",user->nick);
53 long duration = ServerInstance->Duration(parameters[1]);
54 GLine* gl = new GLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2], ih.first.c_str(), ih.second.c_str());
55 if (ServerInstance->XLines->AddLine(gl, user))
59 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent G-line for %s.",user->nick,parameters[0]);
63 time_t c_requires_crap = duration + ServerInstance->Time();
64 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires on %s",user->nick,parameters[0],
65 ServerInstance->TimeString(c_requires_crap).c_str());
68 ServerInstance->XLines->ApplyLines();
73 user->WriteServ("NOTICE %s :*** G-Line for %s already exists",user->nick,parameters[0]);
79 if (ServerInstance->XLines->DelLine(parameters[0],"G",user))
81 ServerInstance->SNO->WriteToSnoMask('x',"%s Removed G-line on %s.",user->nick,parameters[0]);
85 user->WriteServ("NOTICE %s :*** G-line %s not found in list, try /stats g.",user->nick,parameters[0]);