Lets an account keep its last-seen/online line in INFO visible only to itself and to opers. Default stays public (Anope's default). Accepts STATUS (with USERMASK as an alias) per Anope's SET HIDE <field> grammar.
50 lines
2.4 KiB
Rust
50 lines
2.4 KiB
Rust
use echo_api::{human_time, NetView, Priv, Store};
|
|
use echo_api::{Sender, ServiceCtx};
|
|
|
|
// INFO [account]: show an account's registration details. The email and other
|
|
// private fields are shown to the account's own owner, or to an oper with the
|
|
// auspex privilege.
|
|
pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, net: &dyn NetView, db: &dyn Store) {
|
|
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;
|
|
};
|
|
let is_owner = from.account == Some(acct.name.as_str());
|
|
let privileged = is_owner || from.privs.has(Priv::Auspex);
|
|
ctx.notice(me, from.uid, format!("Information for \x02{}\x02:", acct.name));
|
|
ctx.notice(me, from.uid, format!(" Registered : {}", human_time(acct.ts)));
|
|
// Last-seen is public by default; SET HIDE STATUS keeps it to owner and opers.
|
|
if privileged || !acct.hide_status {
|
|
let last_seen = if net.uids_logged_into(&acct.name).is_empty() {
|
|
human_time(acct.last_seen)
|
|
} else {
|
|
"now (online)".to_string()
|
|
};
|
|
ctx.notice(me, from.uid, format!(" Last seen : {last_seen}"));
|
|
}
|
|
// A greet is public — the bot shows it in-channel to everyone anyway.
|
|
if !acct.greet.is_empty() {
|
|
ctx.notice(me, from.uid, format!(" Greet : {}", acct.greet));
|
|
}
|
|
if privileged {
|
|
if let Some(s) = db.suspension(&acct.name) {
|
|
ctx.notice(me, from.uid, format!(" Suspended : by \x02{}\x02 — {}", s.by, s.reason));
|
|
}
|
|
match &acct.email {
|
|
Some(email) if acct.verified => ctx.notice(me, from.uid, format!(" Email : {email}")),
|
|
Some(email) => ctx.notice(me, from.uid, format!(" Email : {email} (unconfirmed)")),
|
|
None => ctx.notice(me, from.uid, " Email : (none set)"),
|
|
}
|
|
let ajoin = db.ajoin_list(&acct.name);
|
|
if !ajoin.is_empty() {
|
|
ctx.notice(me, from.uid, format!(" Auto-join : {} channel(s) — see \x02AJOIN LIST\x02", ajoin.len()));
|
|
}
|
|
}
|
|
// A staff note is for operators' eyes only, never the account's owner.
|
|
if from.privs.has(Priv::Auspex) {
|
|
if let Some(note) = db.account_note(&acct.name) {
|
|
ctx.notice(me, from.uid, format!(" Staff note : {note}"));
|
|
}
|
|
}
|
|
}
|