MemoServ: add CANCEL, CHECK, and INFO
All checks were successful
CI / check (push) Successful in 3m49s
All checks were successful
CI / check (push) Successful in 3m49s
CANCEL recalls the sender's most recent unread memo to a target (one the recipient already read can't be recalled); CHECK reports whether the last memo you sent someone has been read; INFO summarises your mailbox. Adds memo_cancel/memo_check store methods and shares MAX_MEMOS from the module root instead of duplicating it in send.rs.
This commit is contained in:
parent
a26ee722d1
commit
98ecbca414
9 changed files with 118 additions and 2 deletions
|
|
@ -14,14 +14,26 @@ mod list;
|
|||
mod read;
|
||||
#[path = "del.rs"]
|
||||
mod del;
|
||||
#[path = "cancel.rs"]
|
||||
mod cancel;
|
||||
#[path = "check.rs"]
|
||||
mod check;
|
||||
#[path = "info.rs"]
|
||||
mod info;
|
||||
|
||||
const BLURB: &str = "MemoServ delivers messages to registered users, online or not. You must be identified to use it.";
|
||||
|
||||
// A full mailbox rejects new memos, so nobody can be flooded.
|
||||
pub(crate) const MAX_MEMOS: usize = 30;
|
||||
|
||||
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." },
|
||||
HelpEntry { cmd: "CANCEL", summary: "recall a memo you sent", detail: "Syntax: \x02CANCEL <nick>\x02\nRecalls the last memo you sent them, as long as they haven't read it yet." },
|
||||
HelpEntry { cmd: "CHECK", summary: "see if a memo was read", detail: "Syntax: \x02CHECK <nick>\x02\nReports whether the last memo you sent them has been read." },
|
||||
HelpEntry { cmd: "INFO", summary: "your mailbox summary", detail: "Syntax: \x02INFO\x02\nShows how many memos you have, how many are unread, and your capacity." },
|
||||
];
|
||||
|
||||
pub struct MemoServ {
|
||||
|
|
@ -60,6 +72,9 @@ impl Service for MemoServ {
|
|||
Some("LIST") => list::handle(me, from, account, ctx, db),
|
||||
Some("READ") => read::handle(me, from, account, args, ctx, db),
|
||||
Some("DEL") | Some("DELETE") => del::handle(me, from, account, args, ctx, db),
|
||||
Some("CANCEL") => cancel::handle(me, from, account, args, ctx, db),
|
||||
Some("CHECK") => check::handle(me, from, account, args, ctx, db),
|
||||
Some("INFO") => info::handle(me, from, account, ctx, db),
|
||||
Some(other) => ctx.notice(me, from.uid, format!("I don't know the command \x02{other}\x02. Try \x02HELP\x02.")),
|
||||
None => {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue