#include "inspircd.h"
#include "xline.h"
-/* $ModDesc: Implements SVSHOLD. Like Q:Lines, but can only be added/removed by Services. */
+namespace
+{
+ bool silent;
+}
/** Holds a SVSHold item
*/
return InspIRCd::Match(s, nickname);
}
+ void DisplayExpiry()
+ {
+ if (!silent)
+ {
+ ServerInstance->SNO->WriteToSnoMask('x', "Removing expired SVSHOLD %s (set by %s %ld seconds ago)",
+ nickname.c_str(), source.c_str(), (long)(ServerInstance->Time() - set_time));
+ }
+ }
+
const std::string& Displayable()
{
return nickname;
CommandSvshold(Module* Creator) : Command(Creator, "SVSHOLD", 1)
{
flags_needed = 'o'; this->syntax = "<nickname> [<duration> :<reason>]";
- TRANSLATE4(TR_TEXT, TR_TEXT, TR_TEXT, TR_END);
}
CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
/* syntax: svshold nickname time :reason goes here */
/* 'time' is a human-readable timestring, like 2d3h2s. */
- if (!ServerInstance->ULine(user->server))
+ if (!user->server->IsULine())
{
/* don't allow SVSHOLD from non-ulined clients */
return CMD_FAILURE;
{
if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "SVSHOLD", user))
{
- ServerInstance->SNO->WriteToSnoMask('x',"%s removed SVSHOLD on %s",user->nick.c_str(),parameters[0].c_str());
+ if (!silent)
+ ServerInstance->SNO->WriteToSnoMask('x',"%s removed SVSHOLD on %s",user->nick.c_str(),parameters[0].c_str());
}
else
{
if (ServerInstance->XLines->AddLine(r, user))
{
+ if (silent)
+ return CMD_SUCCESS;
+
if (!duration)
{
ServerInstance->SNO->WriteGlobalSno('x', "%s added permanent SVSHOLD for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
- std::string timestr = ServerInstance->TimeString(c_requires_crap);
+ std::string timestr = InspIRCd::TimeString(c_requires_crap);
ServerInstance->SNO->WriteGlobalSno('x', "%s added timed SVSHOLD for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), parameters[2].c_str());
}
}
void init() CXX11_OVERRIDE
{
ServerInstance->XLines->RegisterFactory(&s);
- ServerInstance->Modules->AddService(cmd);
- Implementation eventlist[] = { I_OnUserPreNick, I_OnStats };
- ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
+ }
+
+ void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
+ {
+ ConfigTag* tag = ServerInstance->Config->ConfValue("svshold");
+ silent = tag->getBool("silent", true);
}
ModResult OnStats(char symbol, User* user, string_list &out) CXX11_OVERRIDE
if (rl)
{
- user->WriteServ( "432 %s %s :Services reserved nickname: %s", user->nick.c_str(), newnick.c_str(), rl->reason.c_str());
+ user->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Services reserved nickname: %s", newnick.c_str(), rl->reason.c_str());
return MOD_RES_DENY;
}