Migrate interpolated service messages to the t! macro (8 modules)

This commit is contained in:
Jean Chevronnet 2026-07-19 23:22:56 +00:00
parent b462d37bd5
commit d207c3d60d
No known key found for this signature in database
133 changed files with 782 additions and 702 deletions

View file

@ -1,4 +1,4 @@
use echo_api::{Priv, Sender, ServiceCtx};
use echo_api::{t, Priv, Sender, ServiceCtx};
// SHUTDOWN / RESTART [reason]: stop the services process. `restart` selects
// which — a restart exits so a supervisor respawns us, a shutdown stays down.
@ -7,13 +7,13 @@ use echo_api::{Priv, Sender, ServiceCtx};
pub fn handle(me: &str, from: &Sender, restart: bool, args: &[&str], ctx: &mut ServiceCtx) {
let cmd = if restart { "RESTART" } else { "SHUTDOWN" };
if !from.privs.has(Priv::Root) {
ctx.notice(me, from.uid, format!("Access denied — {cmd} needs the \x02root\x02 privilege."));
ctx.notice(me, from.uid, t!(ctx, "Access denied — {cmd} needs the \x02root\x02 privilege.", cmd = cmd));
return;
}
let reason = if args.len() > 1 { args[1..].join(" ") } else { format!("Services {}", if restart { "restarting" } else { "shutting down" }) };
let by = from.account.unwrap_or(from.nick);
ctx.global(me, format!("[\x02Network\x02] Services are {} ({reason}).", if restart { "restarting" } else { "going down" }));
ctx.notice(me, from.uid, format!("Services are {}.", if restart { "restarting" } else { "shutting down" }));
ctx.notice(me, from.uid, if restart { "Services are restarting." } else { "Services are shutting down." });
// The action is last, so the notices above are flushed before we exit.
ctx.shutdown(restart, format!("{cmd} by {by}: {reason}"));
}