mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Add Duration::ToHuman and update messages to use it.
This commit is contained in:
parent
5ea0bfff6f
commit
2102b065d4
@ -38,6 +38,13 @@ namespace Duration
|
|||||||
*/
|
*/
|
||||||
CoreExport bool IsValid(const std::string& str);
|
CoreExport bool IsValid(const std::string& str);
|
||||||
|
|
||||||
|
/** Converts a number of seconds to a human-readable representation.
|
||||||
|
*
|
||||||
|
* e.g. 33,019,565 will result in 1 year, 2 weeks, 3 days, 4 hours, 6
|
||||||
|
* minutes, 5 seconds.
|
||||||
|
*/
|
||||||
|
CoreExport std::string ToHuman(unsigned long duration);
|
||||||
|
|
||||||
/** Converts a number of seconds to a duration string.
|
/** Converts a number of seconds to a duration string.
|
||||||
*
|
*
|
||||||
* e.g. 33,019,565 will result in 1y2w3d4h6m5s which represents one year,
|
* e.g. 33,019,565 will result in 1y2w3d4h6m5s which represents one year,
|
||||||
|
@ -217,7 +217,7 @@ public:
|
|||||||
std::string extra;
|
std::string extra;
|
||||||
if (oper->IsAway())
|
if (oper->IsAway())
|
||||||
{
|
{
|
||||||
const std::string awayperiod = Duration::ToString(ServerInstance->Time() - oper->away->time);
|
const std::string awayperiod = Duration::ToHuman(ServerInstance->Time() - oper->away->time);
|
||||||
const std::string awaytime = Time::ToString(oper->away->time);
|
const std::string awaytime = Time::ToString(oper->away->time);
|
||||||
|
|
||||||
extra = INSP_FORMAT(": away for {} [since {}] ({})", awayperiod, awaytime, oper->away->message);
|
extra = INSP_FORMAT(": away for {} [since {}] ({})", awayperiod, awaytime, oper->away->message);
|
||||||
@ -226,7 +226,7 @@ public:
|
|||||||
auto* loper = IS_LOCAL(oper);
|
auto* loper = IS_LOCAL(oper);
|
||||||
if (loper)
|
if (loper)
|
||||||
{
|
{
|
||||||
const std::string idleperiod = Duration::ToString(ServerInstance->Time() - loper->idle_lastmsg);
|
const std::string idleperiod = Duration::ToHuman(ServerInstance->Time() - loper->idle_lastmsg);
|
||||||
const std::string idletime = Time::ToString(loper->idle_lastmsg);
|
const std::string idletime = Time::ToString(loper->idle_lastmsg);
|
||||||
|
|
||||||
extra += INSP_FORMAT("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime);
|
extra += INSP_FORMAT("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime);
|
||||||
|
@ -83,7 +83,7 @@ CmdResult CommandEline::Handle(User* user, const Params& parameters)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed E-line on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed E-line on {}, expires in {} (on {}): {}",
|
||||||
user->nick, target, Duration::ToString(duration), Time::FromNow(duration), el->reason);
|
user->nick, target, Duration::ToHuman(duration), Time::FromNow(duration), el->reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -90,7 +90,7 @@ CmdResult CommandGline::Handle(User* user, const Params& parameters)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed G-line on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed G-line on {}, expires in {} (on {}): {}",
|
||||||
user->nick, target, Duration::ToString(duration), Time::FromNow(duration), gl->reason);
|
user->nick, target, Duration::ToHuman(duration), Time::FromNow(duration), gl->reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInstance->XLines->ApplyLines();
|
ServerInstance->XLines->ApplyLines();
|
||||||
|
@ -90,7 +90,7 @@ CmdResult CommandKline::Handle(User* user, const Params& parameters)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed K-line on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed K-line on {}, expires in {} (on {}): {}",
|
||||||
user->nick, target, Duration::ToString(duration), Time::FromNow(duration), kl->reason);
|
user->nick, target, Duration::ToHuman(duration), Time::FromNow(duration), kl->reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInstance->XLines->ApplyLines();
|
ServerInstance->XLines->ApplyLines();
|
||||||
|
@ -72,7 +72,7 @@ CmdResult CommandQline::Handle(User* user, const Params& parameters)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Q-line on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Q-line on {}, expires in {} (on {}): {}",
|
||||||
user->nick, parameters[0], Duration::ToString(duration), Time::FromNow(duration), ql->reason);
|
user->nick, parameters[0], Duration::ToHuman(duration), Time::FromNow(duration), ql->reason);
|
||||||
}
|
}
|
||||||
ServerInstance->XLines->ApplyLines();
|
ServerInstance->XLines->ApplyLines();
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ CmdResult CommandZline::Handle(User* user, const Params& parameters)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Z-line on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Z-line on {}, expires in {} (on {}): {}",
|
||||||
user->nick, ipaddr, Duration::ToString(duration), Time::FromNow(duration), zl->reason);
|
user->nick, ipaddr, Duration::ToHuman(duration), Time::FromNow(duration), zl->reason);
|
||||||
}
|
}
|
||||||
ServerInstance->XLines->ApplyLines();
|
ServerInstance->XLines->ApplyLines();
|
||||||
}
|
}
|
||||||
|
@ -504,6 +504,77 @@ std::string Duration::ToString(unsigned long duration)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
std::string Duration::ToHuman(unsigned long duration)
|
||||||
|
{
|
||||||
|
if (duration == 0)
|
||||||
|
return "0 seconds";
|
||||||
|
|
||||||
|
std::string ret;
|
||||||
|
|
||||||
|
const auto years = (duration / SECONDS_PER_YEAR);
|
||||||
|
if (years)
|
||||||
|
{
|
||||||
|
ret = INSP_FORMAT("{} {}", years, years == 1 ? "year" : "years");
|
||||||
|
duration -= (years * SECONDS_PER_YEAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto weeks = (duration / SECONDS_PER_WEEK);
|
||||||
|
if (weeks)
|
||||||
|
{
|
||||||
|
ret += ret.empty() ? "" : ", ";
|
||||||
|
ret += INSP_FORMAT("{} {}", weeks, weeks == 1 ? "week" : "weeks");
|
||||||
|
duration -= (weeks * SECONDS_PER_WEEK);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto days = (duration / SECONDS_PER_DAY);
|
||||||
|
if (days)
|
||||||
|
{
|
||||||
|
ret += ret.empty() ? "" : ", ";
|
||||||
|
ret += INSP_FORMAT("{} {}", days, days == 1 ? "day" : "days");
|
||||||
|
duration -= (days * SECONDS_PER_DAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto hours = (duration / SECONDS_PER_HOUR);
|
||||||
|
if (hours)
|
||||||
|
{
|
||||||
|
ret += ret.empty() ? "" : ", ";
|
||||||
|
ret += INSP_FORMAT("{} {}", hours, hours == 1 ? "hour" : "hours");
|
||||||
|
duration -= (hours * SECONDS_PER_HOUR);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto minutes = (duration / SECONDS_PER_MINUTE);
|
||||||
|
if (minutes)
|
||||||
|
{
|
||||||
|
ret += ret.empty() ? "" : ", ";
|
||||||
|
ret += INSP_FORMAT("{} {}", minutes, minutes == 1 ? "minute" : "minutes");
|
||||||
|
duration -= (minutes * SECONDS_PER_MINUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (duration)
|
||||||
|
{
|
||||||
|
ret += ret.empty() ? "" : ", ";
|
||||||
|
ret += INSP_FORMAT("{} {}", duration, duration == 1 ? "second" : "seconds");
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto first_comma = ret.find(',');
|
||||||
|
const auto last_comma = ret.rfind(',');
|
||||||
|
if (first_comma != std::string::npos)
|
||||||
|
{
|
||||||
|
if (first_comma == last_comma)
|
||||||
|
{
|
||||||
|
// BEFORE: 1 minute, 2 seconds
|
||||||
|
// AFTER: 1 minute and 2 seconds
|
||||||
|
ret.replace(last_comma, 1, " and");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// BEFORE: 1 hour, 2 minutes, 3 seconds
|
||||||
|
// AFTER: 1 hour, 2 minutes, and 3 seconds
|
||||||
|
ret.insert(last_comma + 1, " and");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Time::ToString(time_t curtime, const char* format, bool utc)
|
std::string Time::ToString(time_t curtime, const char* format, bool utc)
|
||||||
{
|
{
|
||||||
|
@ -792,7 +792,7 @@ private:
|
|||||||
else if (certinfo->activation >= ServerInstance->Time())
|
else if (certinfo->activation >= ServerInstance->Time())
|
||||||
{
|
{
|
||||||
certinfo->error = INSP_FORMAT("Certificate not active for {} (on {})",
|
certinfo->error = INSP_FORMAT("Certificate not active for {} (on {})",
|
||||||
Duration::ToString(certinfo->activation - ServerInstance->Time()),
|
Duration::ToHuman(certinfo->activation - ServerInstance->Time()),
|
||||||
Time::ToString(certinfo->activation));
|
Time::ToString(certinfo->activation));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,7 +805,7 @@ private:
|
|||||||
else if (certinfo->expiration <= ServerInstance->Time())
|
else if (certinfo->expiration <= ServerInstance->Time())
|
||||||
{
|
{
|
||||||
certinfo->error = INSP_FORMAT("Certificate expired {} ago (on {})",
|
certinfo->error = INSP_FORMAT("Certificate expired {} ago (on {})",
|
||||||
Duration::ToString(ServerInstance->Time() - certinfo->expiration),
|
Duration::ToHuman(ServerInstance->Time() - certinfo->expiration),
|
||||||
Time::ToString(certinfo->expiration));
|
Time::ToString(certinfo->expiration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,7 +635,7 @@ private:
|
|||||||
if (activated != -1 && activated != 0)
|
if (activated != -1 && activated != 0)
|
||||||
{
|
{
|
||||||
certinfo->error = INSP_FORMAT("Certificate not active for {} (on {})",
|
certinfo->error = INSP_FORMAT("Certificate not active for {} (on {})",
|
||||||
Duration::ToString(certinfo->activation - ServerInstance->Time()),
|
Duration::ToHuman(certinfo->activation - ServerInstance->Time()),
|
||||||
Time::ToString(certinfo->activation));
|
Time::ToString(certinfo->activation));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,7 +643,7 @@ private:
|
|||||||
if (expired != 0 && expired != 1)
|
if (expired != 0 && expired != 1)
|
||||||
{
|
{
|
||||||
certinfo->error = INSP_FORMAT("Certificate expired {} ago (on {})",
|
certinfo->error = INSP_FORMAT("Certificate expired {} ago (on {})",
|
||||||
Duration::ToString(ServerInstance->Time() - certinfo->expiration),
|
Duration::ToHuman(ServerInstance->Time() - certinfo->expiration),
|
||||||
Time::ToString(certinfo->expiration));
|
Time::ToString(certinfo->expiration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed CBan on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed CBan on {}, expires in {} (on {}): {}",
|
||||||
user->nick, parameters[0], Duration::ToString(duration), Time::FromNow(duration), r->reason);
|
user->nick, parameters[0], Duration::ToHuman(duration), Time::FromNow(duration), r->reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -283,7 +283,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto message = INSP_FORMAT("Replaying up to {} lines of pre-join history", list->maxlen);
|
auto message = INSP_FORMAT("Replaying up to {} lines of pre-join history", list->maxlen);
|
||||||
if (list->maxtime > 0)
|
if (list->maxtime > 0)
|
||||||
message += INSP_FORMAT(" from the last {}", Duration::ToString(list->maxtime));
|
message += INSP_FORMAT(" from the last {}", Duration::ToHuman(list->maxtime));
|
||||||
memb->WriteNotice(message);
|
memb->WriteNotice(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Z-line on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Z-line on {}, expires in {} (on {}): {}",
|
||||||
zl->source, maskstr, Duration::ToString(zl->duration),
|
zl->source, maskstr, Duration::ToHuman(zl->duration),
|
||||||
Time::ToString(zl->expiry), zl->reason);
|
Time::ToString(zl->expiry), zl->reason);
|
||||||
ServerInstance->SNO.WriteGlobalSno('a', "Connect flooding from IP range {} ({})", maskstr, threshold);
|
ServerInstance->SNO.WriteGlobalSno('a', "Connect flooding from IP range {} ({})", maskstr, threshold);
|
||||||
connects.erase(i);
|
connects.erase(i);
|
||||||
|
@ -325,7 +325,7 @@ public:
|
|||||||
|
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
user->WriteNumeric(RPL_DCCALLOWTIMED, user->nick, INSP_FORMAT("Added {} to DCCALLOW list for {}", target->nick, Duration::ToString(length)));
|
user->WriteNumeric(RPL_DCCALLOWTIMED, user->nick, INSP_FORMAT("Added {} to DCCALLOW list for {}", target->nick, Duration::ToHuman(length)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -295,7 +295,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed {} on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed {} on {}, expires in {} (on {}): {}",
|
||||||
line->source, type, line->Displayable(), Duration::ToString(line->duration),
|
line->source, type, line->Displayable(), Duration::ToHuman(line->duration),
|
||||||
Time::ToString(line->expiry), line->reason);
|
Time::ToString(line->expiry), line->reason);
|
||||||
ServerInstance->XLines->ApplyLines();
|
ServerInstance->XLines->ApplyLines();
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ CmdResult CommandFilter::Handle(User* user, const Params& parameters)
|
|||||||
if (result.first)
|
if (result.first)
|
||||||
{
|
{
|
||||||
const std::string message = INSP_FORMAT("'{}', type '{}'{}, flags '{}', reason: {}", freeform, parameters[1],
|
const std::string message = INSP_FORMAT("'{}', type '{}'{}, flags '{}', reason: {}", freeform, parameters[1],
|
||||||
(duration ? INSP_FORMAT(", duration '{}'", Duration::ToString(duration)) : ""),
|
(duration ? INSP_FORMAT(", duration '{}'", Duration::ToHuman(duration)) : ""),
|
||||||
flags, parameters[reasonindex]);
|
flags, parameters[reasonindex]);
|
||||||
|
|
||||||
user->WriteNotice("*** Added filter " + message);
|
user->WriteNotice("*** Added filter " + message);
|
||||||
@ -472,7 +472,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, MessageTarget& msgtarget, M
|
|||||||
{
|
{
|
||||||
auto* sh = new Shun(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress());
|
auto* sh = new Shun(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress());
|
||||||
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was shunned for {} (expires on {}) because their message to {} matched {} ({})",
|
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was shunned for {} (expires on {}) because their message to {} matched {} ({})",
|
||||||
user->nick, sh->Displayable(), Duration::ToString(f->duration),
|
user->nick, sh->Displayable(), Duration::ToHuman(f->duration),
|
||||||
Time::FromNow(f->duration),
|
Time::FromNow(f->duration),
|
||||||
msgtarget.GetName(), f->freeform, f->reason);
|
msgtarget.GetName(), f->freeform, f->reason);
|
||||||
if (ServerInstance->XLines->AddLine(sh, nullptr))
|
if (ServerInstance->XLines->AddLine(sh, nullptr))
|
||||||
@ -486,7 +486,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, MessageTarget& msgtarget, M
|
|||||||
{
|
{
|
||||||
auto* gl = new GLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, "*", user->GetAddress());
|
auto* gl = new GLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, "*", user->GetAddress());
|
||||||
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was G-lined for {} (expires on {}) because their message to {} matched {} ({})",
|
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was G-lined for {} (expires on {}) because their message to {} matched {} ({})",
|
||||||
user->nick, gl->Displayable(), Duration::ToString(f->duration),
|
user->nick, gl->Displayable(), Duration::ToHuman(f->duration),
|
||||||
Time::FromNow(f->duration),
|
Time::FromNow(f->duration),
|
||||||
msgtarget.GetName(), f->freeform, f->reason);
|
msgtarget.GetName(), f->freeform, f->reason);
|
||||||
if (ServerInstance->XLines->AddLine(gl, nullptr))
|
if (ServerInstance->XLines->AddLine(gl, nullptr))
|
||||||
@ -500,7 +500,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, MessageTarget& msgtarget, M
|
|||||||
{
|
{
|
||||||
auto* zl = new ZLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress());
|
auto* zl = new ZLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress());
|
||||||
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was Z-lined for {} (expires on {}) because their message to {} matched {} ({})",
|
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was Z-lined for {} (expires on {}) because their message to {} matched {} ({})",
|
||||||
user->nick, zl->Displayable(), Duration::ToString(f->duration),
|
user->nick, zl->Displayable(), Duration::ToHuman(f->duration),
|
||||||
Time::FromNow(f->duration),
|
Time::FromNow(f->duration),
|
||||||
msgtarget.GetName(), f->freeform, f->reason);
|
msgtarget.GetName(), f->freeform, f->reason);
|
||||||
if (ServerInstance->XLines->AddLine(zl, nullptr))
|
if (ServerInstance->XLines->AddLine(zl, nullptr))
|
||||||
@ -578,7 +578,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params&
|
|||||||
auto* gl = new GLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, "*", user->GetAddress());
|
auto* gl = new GLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, "*", user->GetAddress());
|
||||||
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was G-lined for {} (expires on {}) because their {} message matched {} ({})",
|
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was G-lined for {} (expires on {}) because their {} message matched {} ({})",
|
||||||
user->nick, gl->Displayable(),
|
user->nick, gl->Displayable(),
|
||||||
Duration::ToString(f->duration),
|
Duration::ToHuman(f->duration),
|
||||||
Time::FromNow(f->duration),
|
Time::FromNow(f->duration),
|
||||||
command, f->freeform, f->reason);
|
command, f->freeform, f->reason);
|
||||||
|
|
||||||
@ -594,7 +594,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params&
|
|||||||
auto* zl = new ZLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress());
|
auto* zl = new ZLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress());
|
||||||
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was Z-lined for {} (expires on {}) because their {} message matched {} ({})",
|
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was Z-lined for {} (expires on {}) because their {} message matched {} ({})",
|
||||||
user->nick, zl->Displayable(),
|
user->nick, zl->Displayable(),
|
||||||
Duration::ToString(f->duration),
|
Duration::ToHuman(f->duration),
|
||||||
Time::FromNow(f->duration),
|
Time::FromNow(f->duration),
|
||||||
command, f->freeform, f->reason);
|
command, f->freeform, f->reason);
|
||||||
|
|
||||||
@ -611,7 +611,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params&
|
|||||||
auto* sh = new Shun(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress());
|
auto* sh = new Shun(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress());
|
||||||
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was shunned for {} (expires on {}) because their {} message matched {} ({})",
|
ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was shunned for {} (expires on {}) because their {} message matched {} ({})",
|
||||||
user->nick, sh->Displayable(),
|
user->nick, sh->Displayable(),
|
||||||
Duration::ToString(f->duration),
|
Duration::ToHuman(f->duration),
|
||||||
Time::FromNow(f->duration),
|
Time::FromNow(f->duration),
|
||||||
command, f->freeform, f->reason);
|
command, f->freeform, f->reason);
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public:
|
|||||||
std::string extra;
|
std::string extra;
|
||||||
if (helper->IsAway())
|
if (helper->IsAway())
|
||||||
{
|
{
|
||||||
const std::string awayperiod = Duration::ToString(ServerInstance->Time() - helper->away->time);
|
const std::string awayperiod = Duration::ToHuman(ServerInstance->Time() - helper->away->time);
|
||||||
const std::string awaytime = Time::ToString(helper->away->time);
|
const std::string awaytime = Time::ToString(helper->away->time);
|
||||||
|
|
||||||
extra = INSP_FORMAT(": away for {} [since {}] ({})", awayperiod, awaytime, helper->away->message);
|
extra = INSP_FORMAT(": away for {} [since {}] ({})", awayperiod, awaytime, helper->away->message);
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
auto* lhelper = IS_LOCAL(helper);
|
auto* lhelper = IS_LOCAL(helper);
|
||||||
if (lhelper)
|
if (lhelper)
|
||||||
{
|
{
|
||||||
const std::string idleperiod = Duration::ToString(ServerInstance->Time() - lhelper->idle_lastmsg);
|
const std::string idleperiod = Duration::ToHuman(ServerInstance->Time() - lhelper->idle_lastmsg);
|
||||||
const std::string idletime = Time::ToString(lhelper->idle_lastmsg);
|
const std::string idletime = Time::ToString(lhelper->idle_lastmsg);
|
||||||
|
|
||||||
extra += INSP_FORMAT("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime);
|
extra += INSP_FORMAT("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime);
|
||||||
|
@ -157,7 +157,7 @@ public:
|
|||||||
std::string extra;
|
std::string extra;
|
||||||
if (oper->IsAway())
|
if (oper->IsAway())
|
||||||
{
|
{
|
||||||
const std::string awayperiod = Duration::ToString(ServerInstance->Time() - oper->away->time);
|
const std::string awayperiod = Duration::ToHuman(ServerInstance->Time() - oper->away->time);
|
||||||
const std::string awaytime = Time::ToString(oper->away->time);
|
const std::string awaytime = Time::ToString(oper->away->time);
|
||||||
|
|
||||||
extra = INSP_FORMAT(": away for {} [since {}] ({})", awayperiod, awaytime, oper->away->message);
|
extra = INSP_FORMAT(": away for {} [since {}] ({})", awayperiod, awaytime, oper->away->message);
|
||||||
@ -166,7 +166,7 @@ public:
|
|||||||
auto* loper = IS_LOCAL(oper);
|
auto* loper = IS_LOCAL(oper);
|
||||||
if (loper)
|
if (loper)
|
||||||
{
|
{
|
||||||
const std::string idleperiod = Duration::ToString(ServerInstance->Time() - loper->idle_lastmsg);
|
const std::string idleperiod = Duration::ToHuman(ServerInstance->Time() - loper->idle_lastmsg);
|
||||||
const std::string idletime = Time::ToString(loper->idle_lastmsg);
|
const std::string idletime = Time::ToString(loper->idle_lastmsg);
|
||||||
|
|
||||||
extra += INSP_FORMAT("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime);
|
extra += INSP_FORMAT("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime);
|
||||||
|
@ -79,7 +79,7 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Z-line on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Z-line on {}, expires in {} (on {}): {}",
|
||||||
zl->source, u->GetAddress(), Duration::ToString(zl->duration),
|
zl->source, u->GetAddress(), Duration::ToHuman(zl->duration),
|
||||||
Time::ToString(zl->duration), zl->reason);
|
Time::ToString(zl->duration), zl->reason);
|
||||||
}
|
}
|
||||||
added_zline = true;
|
added_zline = true;
|
||||||
@ -182,7 +182,7 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed R-line on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed R-line on {}, expires in {} (on {}): {}",
|
||||||
user->nick, parameters[0], Duration::ToString(duration), Time::FromNow(duration), r->reason);
|
user->nick, parameters[0], Duration::ToHuman(duration), Time::FromNow(duration), r->reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInstance->XLines->ApplyLines();
|
ServerInstance->XLines->ApplyLines();
|
||||||
|
@ -122,7 +122,7 @@ public:
|
|||||||
{
|
{
|
||||||
user->WriteNotice("*** You cannot view the channel list right now. Please {}try again in {}.",
|
user->WriteNotice("*** You cannot view the channel list right now. Please {}try again in {}.",
|
||||||
exemptregistered ? "log in to an account or " : "",
|
exemptregistered ? "log in to an account or " : "",
|
||||||
Duration::ToString(maxwaittime - ServerInstance->Time()));
|
Duration::ToHuman(maxwaittime - ServerInstance->Time()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -128,7 +128,7 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed SHUN on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed SHUN on {}, expires in {} (on {}): {}",
|
||||||
user->nick, target, Duration::ToString(duration),
|
user->nick, target, Duration::ToHuman(duration),
|
||||||
Time::FromNow(duration), expr);
|
Time::FromNow(duration), expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ CmdResult CommandAddLine::Handle(User* usr, Params& params)
|
|||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('X', "{} added a timed {}{} on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('X', "{} added a timed {}{} on {}, expires in {} (on {}): {}",
|
||||||
setter, params[0], params[0].length() <= 2 ? "-line" : "",
|
setter, params[0], params[0].length() <= 2 ? "-line" : "",
|
||||||
params[1], Duration::ToString(xl->duration),
|
params[1], Duration::ToHuman(xl->duration),
|
||||||
Time::ToString(xl->expiry), params[5]);
|
Time::ToString(xl->expiry), params[5]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -436,7 +436,7 @@ void TreeSocket::Close()
|
|||||||
time_t server_uptime = ServerInstance->Time() - this->age;
|
time_t server_uptime = ServerInstance->Time() - this->age;
|
||||||
if (server_uptime)
|
if (server_uptime)
|
||||||
{
|
{
|
||||||
std::string timestr = Duration::ToString(server_uptime);
|
std::string timestr = Duration::ToHuman(server_uptime);
|
||||||
ServerInstance->SNO.WriteGlobalSno('l', "Connection to '\002{}\002' was established for {}", linkID, timestr);
|
ServerInstance->SNO.WriteGlobalSno('l', "Connection to '\002{}\002' was established for {}", linkID, timestr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ public:
|
|||||||
}
|
}
|
||||||
else if (static_cast<time_t>(ServerInstance->Time() + warnexpiring) > cert->GetExpirationTime())
|
else if (static_cast<time_t>(ServerInstance->Time() + warnexpiring) > cert->GetExpirationTime())
|
||||||
{
|
{
|
||||||
const std::string duration = Duration::ToString(cert->GetExpirationTime() - ServerInstance->Time());
|
const std::string duration = Duration::ToHuman(cert->GetExpirationTime() - ServerInstance->Time());
|
||||||
user->WriteNotice("*** Your TLS client certificate expires in " + duration + ".");
|
user->WriteNotice("*** Your TLS client certificate expires in " + duration + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ public:
|
|||||||
if (sendnotice)
|
if (sendnotice)
|
||||||
{
|
{
|
||||||
const std::string message = INSP_FORMAT("Timed ban {} added by {} on {} lasting for {}.",
|
const std::string message = INSP_FORMAT("Timed ban {} added by {} on {} lasting for {}.",
|
||||||
mask, user->nick, channel->name, Duration::ToString(duration));
|
mask, user->nick, channel->name, Duration::ToHuman(duration));
|
||||||
|
|
||||||
// If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
|
// If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
|
||||||
PrefixMode* mh = ServerInstance->Modes.FindNearestPrefixMode(HALFOP_VALUE);
|
PrefixMode* mh = ServerInstance->Modes.FindNearestPrefixMode(HALFOP_VALUE);
|
||||||
|
@ -252,7 +252,7 @@ public:
|
|||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "database: added a timed {}{} on {}, expires in {} (on {}): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "database: added a timed {}{} on {}, expires in {} (on {}): {}",
|
||||||
xl->type, xl->type.length() <= 2 ? "-line" : "", xl->Displayable(),
|
xl->type, xl->type.length() <= 2 ? "-line" : "", xl->Displayable(),
|
||||||
Duration::ToString(xl->duration), Time::FromNow(xl->duration), xl->reason);
|
Duration::ToHuman(xl->duration), Time::FromNow(xl->duration), xl->reason);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -707,7 +707,7 @@ void XLine::DisplayExpiry()
|
|||||||
{
|
{
|
||||||
ServerInstance->SNO.WriteToSnoMask('x', "Removing an expired {}{} on {} (set by {} {} ago): {}",
|
ServerInstance->SNO.WriteToSnoMask('x', "Removing an expired {}{} on {} (set by {} {} ago): {}",
|
||||||
type, (type.length() <= 2 ? "-line" : ""), Displayable(), source,
|
type, (type.length() <= 2 ? "-line" : ""), Displayable(), source,
|
||||||
Duration::ToString(ServerInstance->Time() - set_time), reason);
|
Duration::ToHuman(ServerInstance->Time() - set_time), reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& ELine::Displayable() const
|
const std::string& ELine::Displayable() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user