NickServ: add SET AUTOOP per-account auto-op opt-out

A user with SET AUTOOP OFF is never auto-opped on join, even where they
hold channel access — they op themselves via ChanServ UP. Stored inverted
(no_autoop) so the default stays auto-op. Join gates on both the channel
setting and the account preference; either can opt out.
This commit is contained in:
Jean Chevronnet 2026-07-16 01:37:31 +00:00
parent 0027decdb7
commit 87e21ff85f
No known key found for this signature in database
11 changed files with 111 additions and 11 deletions

View file

@ -21,7 +21,7 @@ impl Db {
ajoin: Vec::new(),
suspension: None,
memos: Vec::new(), memo_ignore: Vec::new(), memo_notify: true, memo_limit: None,
greet: String::new(),
greet: String::new(), no_autoop: false,
vhost: None,
vhost_request: None,
last_seen: now(),
@ -60,7 +60,7 @@ impl Db {
ajoin: Vec::new(),
suspension: None,
memos: Vec::new(), memo_ignore: Vec::new(), memo_notify: true, memo_limit: None,
greet: String::new(),
greet: String::new(), no_autoop: false,
vhost: None,
vhost_request: None,
last_seen: now(),
@ -418,6 +418,22 @@ impl Db {
Ok(())
}
/// Set whether `account` wants to be auto-opped on join (NickServ SET AUTOOP).
pub fn set_account_autoop(&mut self, account: &str, on: bool) -> Result<(), RegError> {
let k = key(account);
if !self.accounts.contains_key(&k) {
return Err(RegError::Internal);
}
self.log.append(Event::AccountAutoOpSet { account: account.to_string(), on }).map_err(|_| RegError::Internal)?;
self.accounts.get_mut(&k).unwrap().no_autoop = !on;
Ok(())
}
/// Whether `account` wants auto-op on join (default true). Unknown = true.
pub fn account_wants_autoop(&self, account: &str) -> bool {
self.accounts.get(&key(account)).is_none_or(|a| !a.no_autoop)
}
/// Replace `account`'s password with freshly derived credentials.
pub fn set_credentials(&mut self, account: &str, creds: Credentials) -> Result<(), RegError> {
let k = key(account);