chanserv: SET PEACE (block acting against equal-or-higher access)

PEACE stops a channel op from using ChanServ KICK/BAN/DEOP/DEVOICE against
someone whose access rank (founder>op>voice) is equal to or above their own.
Adds a typed access_rank on ChannelView and a peace_blocks guard in those
commands. Same typed-settings path as SIGNKICK/PRIVATE; shown in INFO.
This commit is contained in:
Jean Chevronnet 2026-07-13 03:06:58 +00:00
parent 75019c867a
commit 3bf6b2be77
No known key found for this signature in database
7 changed files with 62 additions and 2 deletions

View file

@ -294,6 +294,7 @@ pub struct ChannelView {
// ChanServ SET options.
pub signkick: bool,
pub private: bool,
pub peace: bool,
}
// A single ChanServ SET option, named for the typed `set_channel_setting` call.
@ -301,6 +302,7 @@ pub struct ChannelView {
pub enum ChanSetting {
SignKick,
Private,
Peace,
}
impl ChannelView {
@ -316,6 +318,18 @@ impl ChannelView {
.map(|a| if a.level == "voice" { "+v" } else { "+o" })
}
// A comparable access rank for PEACE: founder 3, op 2, voice 1, none 0.
pub fn access_rank(&self, account: Option<&str>) -> u8 {
let Some(acc) = account else { return 0 };
if self.founder.eq_ignore_ascii_case(acc) {
return 3;
}
self.access
.iter()
.find(|a| a.account.eq_ignore_ascii_case(acc))
.map_or(0, |a| if a.level == "voice" { 1 } else { 2 })
}
// Whether this account holds channel-operator access (founder or op level).
pub fn is_op(&self, account: &str) -> bool {
self.join_mode(account) == Some("+o")