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 * ---------------------------------------------------
16 /** Handle /KILL. These command handlers can be reloaded by the core,
17 * and handle basic RFC1459 commands. Commands within modules work
18 * the same way, however, they can be fully unloaded, where these
21 class CommandKill : public Command
24 /** Constructor for kill.
26 CommandKill ( Module* parent) : Command(parent,"KILL",2,2) { flags_needed = 'o'; syntax = "<nickname> <reason>"; }
28 * @param parameters The parameters to the comamnd
29 * @param pcnt The number of parameters passed to teh command
30 * @param user The user issuing the command
31 * @return A value from CmdResult to indicate command success or failure.
33 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
34 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
36 return ROUTE_BROADCAST;
42 CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User *user)
44 /* Allow comma seperated lists of users for /KILL (thanks w00t) */
45 if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
48 User *u = ServerInstance->FindNick(parameters[0]);
49 char killreason[MAXBUF];
55 * Here, we need to decide how to munge kill messages. Whether to hide killer, what to show opers, etc.
56 * We only do this when the command is being issued LOCALLY, for remote KILL, we just copy the message we got.
58 * This conditional is so that we only append the "Killed (" prefix ONCE. If killer is remote, then the kill
59 * just gets processed and passed on, otherwise, if they are local, it gets prefixed. Makes sense :-) -- w00t
64 * Moved this event inside the IS_LOCAL check also, we don't want half the network killing a user
65 * and the other half not. This would be a bad thing. ;p -- w00t
67 FIRST_MOD_RESULT(OnKill, MOD_RESULT, (user, u, parameters[1]));
69 if (MOD_RESULT == MOD_RES_DENY)
72 if (!ServerInstance->Config->HideKillsServer.empty())
74 // hidekills is on, use it
75 snprintf(killreason, ServerInstance->Config->Limits.MaxQuit, "Killed (%s (%s))", ServerInstance->Config->HideKillsServer.c_str(), parameters[1].c_str());
79 // hidekills is off, do nothing
80 snprintf(killreason, ServerInstance->Config->Limits.MaxQuit, "Killed (%s (%s))", user->nick.c_str(), parameters[1].c_str());
85 /* Leave it alone, remote server has already formatted it */
86 strlcpy(killreason, parameters[1].c_str(), ServerInstance->Config->Limits.MaxQuit);
90 * Now we need to decide whether or not to send a local or remote snotice. Currently this checking is a little flawed.
91 * No time to fix it right now, so left a note. -- w00t
96 ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s!%s@%s (%s)", user->nick.c_str(), u->nick.c_str(), u->ident.c_str(), u->host.c_str(), parameters[1].c_str());
97 FOREACH_MOD(I_OnRemoteKill, OnRemoteKill(user, u, killreason, killreason));
103 * XXX - this isn't entirely correct, servers A - B - C, oper on A, client on C. Oper kills client, A and B will get remote kill
104 * snotices, C will get a local kill snotice. this isn't accurate, and needs fixing at some stage. -- w00t
106 ServerInstance->SNO->WriteToSnoMask('k',"Local Kill by %s: %s!%s@%s (%s)", user->nick.c_str(), u->nick.c_str(), u->ident.c_str(), u->host.c_str(), parameters[1].c_str());
107 ServerInstance->Logs->Log("KILL",DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick.c_str(), ServerInstance->Config->ServerName.c_str(), user->dhost.c_str(), user->nick.c_str(), parameters[1].c_str());
108 /* Bug #419, make sure this message can only occur once even in the case of multiple KILL messages crossing the network, and change to show
109 * hidekillsserver as source if possible
113 u->Write(":%s KILL %s :%s!%s!%s (%s)", ServerInstance->Config->HideKillsServer.empty() ? user->GetFullHost().c_str() : ServerInstance->Config->HideKillsServer.c_str(),
115 ServerInstance->Config->ServerName.c_str(),
117 ServerInstance->Config->HideKillsServer.empty() ? user->nick.c_str() : ServerInstance->Config->HideKillsServer.c_str(),
118 parameters[1].c_str());
123 ServerInstance->Users->QuitUser(u, killreason);
127 user->WriteServ( "401 %s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
135 COMMAND_INIT(CommandKill)