Group the module crates under modules/
The service pseudo-clients and the ircd protocol link sat flat at the repo root, mixed in with the daemon core and the SDK. Move them all under modules/ so the tree separates concerns cleanly: the daemon in src/, the SDK every module links against in api/, and the loadable modules — the pseudo-clients plus the protocol link — in modules/. Workspace members, the daemon's per-crate dependency paths, and each module's api path are updated to match; the docs follow. No code change.
This commit is contained in:
parent
6f76f9722c
commit
ad2a623120
116 changed files with 69 additions and 46 deletions
54
modules/memoserv/src/lib.rs
Normal file
54
modules/memoserv/src/lib.rs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
//! MemoServ delivers short messages ("memos") to registered accounts whether or
|
||||
//! not they are online — they read them next time they identify. Memos are typed
|
||||
//! and event-logged on the account, so they persist and federate like any other
|
||||
//! account data. `lib.rs` holds the dispatcher; each command lives in its own
|
||||
//! file, matching NickServ/ChanServ.
|
||||
|
||||
use fedserv_api::{NetView, Sender, Service, ServiceCtx, Store};
|
||||
|
||||
#[path = "send.rs"]
|
||||
mod send;
|
||||
#[path = "list.rs"]
|
||||
mod list;
|
||||
#[path = "read.rs"]
|
||||
mod read;
|
||||
#[path = "del.rs"]
|
||||
mod del;
|
||||
|
||||
pub struct MemoServ {
|
||||
pub uid: String,
|
||||
}
|
||||
|
||||
impl Service for MemoServ {
|
||||
fn nick(&self) -> &str {
|
||||
"MemoServ"
|
||||
}
|
||||
fn uid(&self) -> &str {
|
||||
&self.uid
|
||||
}
|
||||
fn gecos(&self) -> &str {
|
||||
"Memo Services"
|
||||
}
|
||||
|
||||
fn on_command(&mut self, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, _net: &dyn NetView, db: &mut dyn Store) {
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
// Everything else needs you to be identified (memos are per-account).
|
||||
let Some(account) = from.account else {
|
||||
ctx.notice(me, from.uid, "You must identify to NickServ before using MemoServ.");
|
||||
return;
|
||||
};
|
||||
match cmd.as_deref() {
|
||||
Some("SEND") => send::handle(me, from, account, args, ctx, db),
|
||||
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(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