NickServ: add SET HIDE STATUS for last-seen privacy

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.
This commit is contained in:
Jean Chevronnet 2026-07-16 02:33:55 +00:00
parent 39d7421c06
commit 053f8cf832
No known key found for this signature in database
12 changed files with 116 additions and 19 deletions

View file

@ -10,21 +10,24 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, net:
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 (Anope shows it by default); a live session reads as online.
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}"));
// 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));
}
let is_owner = from.account == Some(acct.name.as_str());
if is_owner || from.privs.has(Priv::Auspex) {
if privileged {
if let Some(s) = db.suspension(&acct.name) {
ctx.notice(me, from.uid, format!(" Suspended : by \x02{}\x02{}", s.by, s.reason));
}