diff --git a/modules/diceserv/src/lib.rs b/modules/diceserv/src/lib.rs index eb10664..6e0b1ab 100644 --- a/modules/diceserv/src/lib.rs +++ b/modules/diceserv/src/lib.rs @@ -6,7 +6,7 @@ //! `lib.rs` holds the dispatcher; the command lives in roll.rs and the //! expression evaluator in expr.rs. -use echo_api::{HelpEntry, NetView, Sender, Service, ServiceCtx, Store}; +use echo_api::{t, HelpEntry, NetView, Sender, Service, ServiceCtx, Store}; #[path = "expr.rs"] mod expr; @@ -49,7 +49,7 @@ impl Service for DiceServ { Some("CALC") => roll::handle(me, from, &args[1..], ctx, false, false), Some("EXCALC") => roll::handle(me, from, &args[1..], ctx, true, false), Some("HELP") | None => echo_api::help(me, from, ctx, BLURB, TOPICS, args.get(1).copied()), - Some(other) => ctx.notice(me, from.uid, format!("I don't know \x02{other}\x02. Try \x02ROLL\x02, \x02CALC\x02, or \x02HELP\x02.")), + Some(other) => ctx.notice(me, from.uid, t!(ctx, "I don't know \x02{other}\x02. Try \x02ROLL\x02, \x02CALC\x02, or \x02HELP\x02.", other = other)), } } } diff --git a/modules/diceserv/src/roll.rs b/modules/diceserv/src/roll.rs index 86c6180..e0a3e69 100644 --- a/modules/diceserv/src/roll.rs +++ b/modules/diceserv/src/roll.rs @@ -1,4 +1,4 @@ -use echo_api::{Sender, ServiceCtx}; +use echo_api::{t, Sender, ServiceCtx}; use super::expr; @@ -19,7 +19,7 @@ pub fn handle(me: &str, from: &Sender, rest: &[&str], ctx: &mut ServiceCtx, exte Some((n, body)) => match n.trim().parse::() { Ok(t) if (1..=MAX_REPEATS).contains(&t) => (t, body.trim()), _ => { - ctx.notice(me, from.uid, format!("The repeat count before \x02~\x02 must be a number from 1 to {MAX_REPEATS}.")); + ctx.notice(me, from.uid, t!(ctx, "The repeat count before \x02~\x02 must be a number from 1 to {max}.", max = MAX_REPEATS)); return; } }, @@ -50,7 +50,7 @@ pub fn handle(me: &str, from: &Sender, rest: &[&str], ctx: &mut ServiceCtx, exte } } Err(why) => { - ctx.notice(me, from.uid, format!("I couldn't roll \x02{body}\x02: {why}.")); + ctx.notice(me, from.uid, t!(ctx, "I couldn't roll \x02{body}\x02: {why}.", body = body, why = why)); return; // the whole batch shares the expression, so it'll fail the same way } } diff --git a/modules/dictserv/src/lib.rs b/modules/dictserv/src/lib.rs index 80f2d06..425f0e1 100644 --- a/modules/dictserv/src/lib.rs +++ b/modules/dictserv/src/lib.rs @@ -6,7 +6,7 @@ //! Works two ways: `/msg DictServ dict cat` (DictServ replies), or the fantasy //! `!dict cat` in a channel with an assigned bot (the bot speaks the answer). -use echo_api::{HelpEntry, NetView, Sender, Service, ServiceCtx, Store}; +use echo_api::{t, HelpEntry, NetView, Sender, Service, ServiceCtx, Store}; // One lookup command: the fantasy/word, the DICT database it queries, and a human // label shown in the reply. Shared by DictServ and the engine's fantasy router so @@ -75,7 +75,7 @@ impl Service for DictServ { if let Some(l) = lookup_for(cmd) { let query = args[1..].join(" "); if query.trim().is_empty() { - ctx.notice(me, from.uid, format!("Give a term to look up, e.g. \x02{} cat\x02.", l.cmd)); + ctx.notice(me, from.uid, t!(ctx, "Give a term to look up, e.g. \x02{cmd} cat\x02.", cmd = l.cmd)); return; } ctx.dict_lookup(me, from.uid, l.database, l.label, query); @@ -85,11 +85,11 @@ impl Service for DictServ { "LOOKUP" | "LIST" => { ctx.notice(me, from.uid, "Lookup commands (use in a channel as \x02!cmd \x02, or here as \x02/msg DictServ cmd \x02):"); for l in LOOKUPS { - ctx.notice(me, from.uid, format!(" \x02{}\x02 — {}", l.cmd, l.label)); + ctx.notice(me, from.uid, t!(ctx, " \x02{cmd}\x02 — {label}", cmd = l.cmd, label = l.label)); } } "HELP" | "" => echo_api::help(me, from, ctx, BLURB, TOPICS, args.get(1).copied()), - other => ctx.notice(me, from.uid, format!("I don't know \x02{other}\x02. Try \x02LOOKUP\x02 for the list, or \x02HELP\x02.")), + other => ctx.notice(me, from.uid, t!(ctx, "I don't know \x02{other}\x02. Try \x02LOOKUP\x02 for the list, or \x02HELP\x02.", other = other)), } } }