Wire centralized HELP into the remaining services
ChanServ, BotServ, HostServ, MemoServ, OperServ, and StatServ now route HELP through the shared renderer with per-command topic tables, so every service supports HELP <command>. The renderer matches slash-grouped names (OP/DEOP/VOICE/DEVOICE) so a paired command resolves as one topic. Adds unit tests for the renderer.
This commit is contained in:
parent
c9e392630b
commit
69a93198ff
7 changed files with 180 additions and 22 deletions
|
|
@ -4,7 +4,7 @@
|
|||
//! account data. `lib.rs` holds the dispatcher; each command lives in its own
|
||||
//! file, matching NickServ/ChanServ.
|
||||
|
||||
use echo_api::{NetView, Sender, Service, ServiceCtx, Store};
|
||||
use echo_api::{HelpEntry, NetView, Sender, Service, ServiceCtx, Store};
|
||||
|
||||
#[path = "send.rs"]
|
||||
mod send;
|
||||
|
|
@ -15,6 +15,15 @@ mod read;
|
|||
#[path = "del.rs"]
|
||||
mod del;
|
||||
|
||||
const BLURB: &str = "MemoServ delivers messages to registered users, online or not. You must be identified to use it.";
|
||||
|
||||
const TOPICS: &[HelpEntry] = &[
|
||||
HelpEntry { cmd: "SEND", summary: "leave a memo for an account", detail: "Syntax: \x02SEND <nick> <text>\x02\nLeaves a memo on a registered account's mailbox." },
|
||||
HelpEntry { cmd: "LIST", summary: "list your memos", detail: "Syntax: \x02LIST\x02\nLists the memos in your mailbox." },
|
||||
HelpEntry { cmd: "READ", summary: "read a memo", detail: "Syntax: \x02READ <num>|NEW|ALL\x02\nReads a memo by number, your unread ones, or all of them." },
|
||||
HelpEntry { cmd: "DEL", summary: "delete a memo", detail: "Syntax: \x02DEL <num>|ALL\x02\nDeletes a memo by number, or your whole mailbox." },
|
||||
];
|
||||
|
||||
pub struct MemoServ {
|
||||
pub uid: String,
|
||||
}
|
||||
|
|
@ -34,7 +43,7 @@ impl Service for MemoServ {
|
|||
let me = self.uid.as_str();
|
||||
let cmd = args.first().map(|s| s.to_ascii_uppercase());
|
||||
if matches!(cmd.as_deref(), Some("HELP") | None) {
|
||||
ctx.notice(me, from.uid, "MemoServ delivers messages to registered users, online or not. Commands: \x02SEND\x02 <nick> <text>, \x02LIST\x02, \x02READ\x02 <num>|NEW|ALL, \x02DEL\x02 <num>|ALL.");
|
||||
echo_api::help(me, from, ctx, BLURB, TOPICS, args.get(1).copied());
|
||||
return;
|
||||
}
|
||||
// Everything else needs you to be identified (memos are per-account).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue