CommandKill::CommandKill(Module* parent)
: Command(parent, "KILL", 2, 2)
+ , protoev(parent, name)
{
flags_needed = 'o';
syntax = "<nickname> <reason>";
TRANSLATE2(TR_CUSTOM, TR_CUSTOM);
}
+class KillMessage : public ClientProtocol::Message
+{
+ public:
+ KillMessage(ClientProtocol::EventProvider& protoev, User* user, LocalUser* target, const std::string& text)
+ : ClientProtocol::Message("KILL", NULL)
+ {
+ if (ServerInstance->Config->HideKillsServer.empty())
+ SetSourceUser(user);
+ else
+ SetSource(ServerInstance->Config->HideKillsServer);
+
+ PushParamRef(target->nick);
+ PushParamRef(text);
+ }
+};
/** Handle /KILL
*/
-CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User *user)
+CmdResult CommandKill::Handle(User* user, const Params& parameters)
{
/* Allow comma seperated lists of users for /KILL (thanks w00t) */
if (CommandParser::LoopCall(user, this, parameters, 0))
killreason.assign(parameters[1], 0, ServerInstance->Config->Limits.MaxQuit);
}
- if (!IS_LOCAL(target))
+ if ((!ServerInstance->Config->HideULineKills) || (!user->server->IsULine()))
{
- // remote kill
- if ((!ServerInstance->Config->HideULineKills) || (!user->server->IsULine()))
+ if (IS_LOCAL(user) && IS_LOCAL(target))
+ ServerInstance->SNO->WriteGlobalSno('k', "Local kill by %s: %s (%s)", user->nick.c_str(), target->GetFullRealHost().c_str(), parameters[1].c_str());
+ else
ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s (%s)", user->nick.c_str(), target->GetFullRealHost().c_str(), parameters[1].c_str());
- this->lastuuid = target->uuid;
}
- else
- {
- if ((!ServerInstance->Config->HideULineKills) || (!user->server->IsULine()))
- {
- if (IS_LOCAL(user))
- ServerInstance->SNO->WriteGlobalSno('k', "Local kill by %s: %s (%s)", user->nick.c_str(), target->GetFullRealHost().c_str(), parameters[1].c_str());
- else
- ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s (%s)", user->nick.c_str(), target->GetFullRealHost().c_str(), parameters[1].c_str());
- }
- ServerInstance->Logs->Log("KILL", LOG_DEFAULT, "LOCAL KILL: %s :%s!%s!%s (%s)", target->nick.c_str(), ServerInstance->Config->ServerName.c_str(), user->dhost.c_str(), user->nick.c_str(), parameters[1].c_str());
-
- target->Write(":%s KILL %s :%s",
- ServerInstance->Config->HideKillsServer.empty() ? user->GetFullHost().c_str() : ServerInstance->Config->HideKillsServer.c_str(),
- target->nick.c_str(),
- parameters[1].c_str());
+ if (IS_LOCAL(target))
+ {
+ LocalUser* localu = IS_LOCAL(target);
+ KillMessage msg(protoev, user, localu, killreason);
+ ClientProtocol::Event killevent(protoev, msg);
+ localu->Send(killevent);
this->lastuuid.clear();
}
+ else
+ {
+ this->lastuuid = target->uuid;
+ }
// send the quit out
ServerInstance->Users->QuitUser(target, killreason);
return CMD_SUCCESS;
}
-RouteDescriptor CommandKill::GetRouting(User* user, const std::vector<std::string>& parameters)
+RouteDescriptor CommandKill::GetRouting(User* user, const Params& parameters)
{
// FindNick() doesn't work here because we quit the target user in Handle() which
// removes it from the nicklist, so we check lastuuid: if it's empty then this KILL
}
-void CommandKill::EncodeParameter(std::string& param, int index)
+void CommandKill::EncodeParameter(std::string& param, unsigned int index)
{
// Manually translate the nick -> uuid (see above), and also the reason (params[1])
// because we decorate it if the oper is local and want remote servers to see the