opmoderated channel mode (+U — route unprivileged messages to ops)

This commit is contained in:
Jean Chevronnet 2026-08-09 01:07:30 +00:00
parent 4a53c80d4d
commit 4d6525cac2
4 changed files with 26 additions and 4 deletions

View file

@ -89,6 +89,7 @@ static CHAN_MODES: &[&(dyn ChanMode + Sync)] = &[
&ALLOWINVITE,
&PERMANENT,
&KICKNOREJOIN,
&OPMODERATED,
];
// --- prefix modes (+q/+a/+o/+h/+v): a per-member rank, needs a nick ----------
@ -307,6 +308,9 @@ fn set_allowinvite(m: &mut ChanModes, v: bool) {
fn set_permanent(m: &mut ChanModes, v: bool) {
m.permanent = v;
}
fn set_opmoderated(m: &mut ChanModes, v: bool) {
m.opmoderated = v;
}
static NOKICKS: Flag = Flag {
ch: 'Q',
set: set_nokicks,
@ -319,6 +323,10 @@ static PERMANENT: Flag = Flag {
ch: 'P',
set: set_permanent,
};
static OPMODERATED: Flag = Flag {
ch: 'U',
set: set_opmoderated,
};
impl ChanMode for Flag {
fn letter(&self) -> char {
@ -1142,7 +1150,7 @@ mod tests {
#[test]
fn registry_covers_all_channel_modes() {
for c in "qaohvbeIklmntiszpONCTcSRMfjFLgGuBQAPJ".chars() {
for c in "qaohvbeIklmntiszpONCTcSRMfjFLgGuBQAPJU".chars() {
assert!(chan_mode(c).is_some(), "missing handler for +{c}");
}
assert!(chan_mode('y').is_none());