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))
ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s (%s)", user->nick.c_str(), target->GetFullRealHost().c_str(), parameters[1].c_str());
}
- if (IS_LOCAL(user) || IS_LOCAL(target))
- ServerInstance->Logs->Log("KILL", LOG_DEFAULT, "%s KILL: %s :%s!%s!%s (%s)",
- IS_LOCAL(user) && IS_LOCAL(target) ? "LOCAL" : "REMOTE",
- target->nick.c_str(),
- ServerInstance->Config->ServerName.c_str(), user->GetDisplayedHost().c_str(), user->nick.c_str(),
- parameters[1].c_str());
-
if (IS_LOCAL(target))
{
- 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());
+ LocalUser* localu = IS_LOCAL(target);
+ KillMessage msg(protoev, user, localu, killreason);
+ ClientProtocol::Event killevent(protoev, msg);
+ localu->Send(killevent);
this->lastuuid.clear();
}
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