botserv: bots join +ao (protected admin + op), keeping op alongside protect
All checks were successful
CI / check (push) Successful in 3m53s
All checks were successful
CI / check (push) Successful in 3m53s
This commit is contained in:
parent
73467b91ca
commit
f2ba876ce4
4 changed files with 12 additions and 11 deletions
|
|
@ -118,8 +118,8 @@ pub enum NetAction {
|
||||||
// Remove one of our pseudo-clients (e.g. a deleted bot) from the network.
|
// Remove one of our pseudo-clients (e.g. a deleted bot) from the network.
|
||||||
QuitUser { uid: String, reason: String },
|
QuitUser { uid: String, reason: String },
|
||||||
// A services pseudo-client (a bot) joins / parts a channel. `modes` are the
|
// A services pseudo-client (a bot) joins / parts a channel. `modes` are the
|
||||||
// status-mode letters it joins with: "a" (protected admin) for BotServ bots,
|
// status-mode letters it joins with: "ao" (protected admin + op) for BotServ
|
||||||
// "o" for the core service pseudo-clients in the services channel.
|
// bots, "o" for the core service pseudo-clients in the services channel.
|
||||||
ServiceJoin { uid: String, channel: String, modes: String },
|
ServiceJoin { uid: String, channel: String, modes: String },
|
||||||
ServicePart { uid: String, channel: String },
|
ServicePart { uid: String, channel: String },
|
||||||
// Set channel modes from services, e.g. +r on a registered channel. `from` is
|
// Set channel modes from services, e.g. +r on a registered channel. `from` is
|
||||||
|
|
|
||||||
|
|
@ -354,8 +354,8 @@ impl Protocol for InspIrcd {
|
||||||
// IJOIN needs a membid (`IJOIN <chan> <membid>`); without it the
|
// IJOIN needs a membid (`IJOIN <chan> <membid>`); without it the
|
||||||
// ircd rejects the whole link with "Insufficient parameters". The
|
// ircd rejects the whole link with "Insufficient parameters". The
|
||||||
// trailing "1 <modes>" is the 4-param form (ts, status modes) — a
|
// trailing "1 <modes>" is the 4-param form (ts, status modes) — a
|
||||||
// BotServ bot joins "+a" (protected admin), core services "+o". ts 1
|
// BotServ bot joins "+ao" (protected admin + op), core services "+o".
|
||||||
// keeps it below the channel TS so the status is always applied.
|
// ts 1 keeps it below the channel TS so the status is always applied.
|
||||||
self.membid += 1;
|
self.membid += 1;
|
||||||
vec![format!(":{} IJOIN {} {} 1 {}", uid, channel, self.membid, modes)]
|
vec![format!(":{} IJOIN {} {} 1 {}", uid, channel, self.membid, modes)]
|
||||||
}
|
}
|
||||||
|
|
@ -745,8 +745,8 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn service_join_ijoin_includes_membid() {
|
fn service_join_ijoin_includes_membid() {
|
||||||
let mut p = proto();
|
let mut p = proto();
|
||||||
let a = p.serialize(&NetAction::ServiceJoin { uid: "00DB00000".into(), channel: "#taverne".into(), modes: "a".into() });
|
let a = p.serialize(&NetAction::ServiceJoin { uid: "00DB00000".into(), channel: "#taverne".into(), modes: "ao".into() });
|
||||||
assert_eq!(a, vec![":00DB00000 IJOIN #taverne 1 1 a".to_string()], "bot joins +a (protected) with a membid");
|
assert_eq!(a, vec![":00DB00000 IJOIN #taverne 1 1 ao".to_string()], "bot joins +ao (protected admin + op) with a membid");
|
||||||
// membid is monotonic across joins; core services join +o
|
// membid is monotonic across joins; core services join +o
|
||||||
let b = p.serialize(&NetAction::ServiceJoin { uid: "00DB00000".into(), channel: "#quizz".into(), modes: "o".into() });
|
let b = p.serialize(&NetAction::ServiceJoin { uid: "00DB00000".into(), channel: "#quizz".into(), modes: "o".into() });
|
||||||
assert_eq!(b, vec![":00DB00000 IJOIN #quizz 2 1 o".to_string()]);
|
assert_eq!(b, vec![":00DB00000 IJOIN #quizz 2 1 o".to_string()]);
|
||||||
|
|
|
||||||
|
|
@ -444,9 +444,10 @@ impl Engine {
|
||||||
for (bot_lc, chan) in &desired {
|
for (bot_lc, chan) in &desired {
|
||||||
if !self.bot_channels.contains(&(bot_lc.clone(), chan.clone())) {
|
if !self.bot_channels.contains(&(bot_lc.clone(), chan.clone())) {
|
||||||
if let Some(uid) = self.bot_uids.get(bot_lc) {
|
if let Some(uid) = self.bot_uids.get(bot_lc) {
|
||||||
// BotServ bots join as protected admins (+a) so ordinary ops
|
// BotServ bots join as protected admins + op (+ao) so they hold
|
||||||
// can't kick or deop them — the standard bot default.
|
// op and ordinary ops still can't kick or deop them — the
|
||||||
out.push(NetAction::ServiceJoin { uid: uid.clone(), channel: chan.clone(), modes: "a".into() });
|
// standard bot default.
|
||||||
|
out.push(NetAction::ServiceJoin { uid: uid.clone(), channel: chan.clone(), modes: "ao".into() });
|
||||||
self.bot_channels.insert((bot_lc.clone(), chan.clone()));
|
self.bot_channels.insert((bot_lc.clone(), chan.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2217,9 +2217,9 @@
|
||||||
ns(&mut e, "000AAAAAC", "IDENTIFY password1");
|
ns(&mut e, "000AAAAAC", "IDENTIFY password1");
|
||||||
bs(&mut e, "000AAAAAC", "BOT ADD Bendy bot serv.host Helper"); // goes live
|
bs(&mut e, "000AAAAAC", "BOT ADD Bendy bot serv.host Helper"); // goes live
|
||||||
|
|
||||||
// The founder assigns the bot: it joins the channel as a protected admin (+a).
|
// The founder assigns the bot: it joins as a protected admin + op (+ao).
|
||||||
let out = bs(&mut e, "000AAAAAB", "ASSIGN #c Bendy");
|
let out = bs(&mut e, "000AAAAAB", "ASSIGN #c Bendy");
|
||||||
assert!(out.iter().any(|a| matches!(a, NetAction::ServiceJoin { channel, modes, .. } if channel == "#c" && modes == "a")), "joins +a on assign: {out:?}");
|
assert!(out.iter().any(|a| matches!(a, NetAction::ServiceJoin { channel, modes, .. } if channel == "#c" && modes == "ao")), "joins +ao on assign: {out:?}");
|
||||||
// Unassigning parts it.
|
// Unassigning parts it.
|
||||||
let out = bs(&mut e, "000AAAAAB", "UNASSIGN #c");
|
let out = bs(&mut e, "000AAAAAB", "UNASSIGN #c");
|
||||||
assert!(out.iter().any(|a| matches!(a, NetAction::ServicePart { channel, .. } if channel == "#c")), "parts on unassign: {out:?}");
|
assert!(out.iter().any(|a| matches!(a, NetAction::ServicePart { channel, .. } if channel == "#c")), "parts on unassign: {out:?}");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue