Set channel mode +r when a channel is registered

ChanServ sends FMODE to mark a registered channel +r (the m_services
c_registered mode), and -r on drop. Sourced from our server, which the
ircd requires for that mode, with a low TS so it applies to the existing
channel.
This commit is contained in:
Jean Chevronnet 2026-07-12 08:33:39 +00:00
parent 89593ebeb4
commit 64500906d8
No known key found for this signature in database
5 changed files with 33 additions and 6 deletions

View file

@ -922,16 +922,20 @@ mod tests {
// Not identified yet: refused.
assert!(notice(&to_cs(&mut e, "000AAAAAB", "REGISTER #room"), "must be identified"));
// Identify, then register.
// Identify, then register: sets +r on the channel.
e.handle(NetEvent::Privmsg { from: "000AAAAAB".into(), to: "42SAAAAAA".into(), text: "IDENTIFY sesame".into() });
assert!(notice(&to_cs(&mut e, "000AAAAAB", "REGISTER #room"), "now registered"));
let out = to_cs(&mut e, "000AAAAAB", "REGISTER #room");
assert!(notice(&out, "now registered"));
assert!(out.iter().any(|a| matches!(a, NetAction::ChannelMode { channel, modes } if channel == "#room" && modes == "+r")), "register sets +r: {out:?}");
assert!(notice(&to_cs(&mut e, "000AAAAAB", "INFO #room"), "alice"));
// A different, unidentified user cannot drop it.
e.handle(NetEvent::UserConnect { uid: "000AAAAAC".into(), nick: "bob".into() });
assert!(notice(&to_cs(&mut e, "000AAAAAC", "DROP #room"), "founder"));
// The founder can.
assert!(notice(&to_cs(&mut e, "000AAAAAB", "DROP #room"), "dropped"));
// The founder can, which also clears +r.
let out = to_cs(&mut e, "000AAAAAB", "DROP #room");
assert!(notice(&out, "dropped"));
assert!(out.iter().any(|a| matches!(a, NetAction::ChannelMode { channel, modes } if channel == "#room" && modes == "-r")), "drop clears +r: {out:?}");
}
}

View file

@ -74,4 +74,12 @@ impl ServiceCtx {
nick: nick.to_string(),
});
}
// Set channel modes from services, e.g. "+r" on a registered channel.
pub fn channel_mode(&mut self, channel: &str, modes: &str) {
self.actions.push(NetAction::ChannelMode {
channel: channel.to_string(),
modes: modes.to_string(),
});
}
}