nickserv: add INFO and ALIST
INFO shows an account's registration date and (to its owner) email; ALIST lists the channels an account founds or has access on. The UTC time formatter moves to the db module so both services share it.
This commit is contained in:
parent
9d6cf3bb08
commit
0427819f86
7 changed files with 115 additions and 32 deletions
20
modules/nickserv/info.rs
Normal file
20
modules/nickserv/info.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use crate::engine::db::{human_time, Db};
|
||||
use crate::engine::service::{Sender, ServiceCtx};
|
||||
|
||||
// INFO [account]: show an account's registration details. The email is shown
|
||||
// only to the account's own owner.
|
||||
pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db: &Db) {
|
||||
let name = args.get(1).copied().unwrap_or(from.nick);
|
||||
let Some(acct) = db.account(name) else {
|
||||
ctx.notice(me, from.uid, format!("\x02{name}\x02 isn't registered."));
|
||||
return;
|
||||
};
|
||||
ctx.notice(me, from.uid, format!("Information for \x02{}\x02:", acct.name));
|
||||
ctx.notice(me, from.uid, format!(" Registered : {}", human_time(acct.ts)));
|
||||
if from.account == Some(acct.name.as_str()) {
|
||||
match &acct.email {
|
||||
Some(email) => ctx.notice(me, from.uid, format!(" Email : {email}")),
|
||||
None => ctx.notice(me, from.uid, " Email : (none set)"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue