ChanServ: add OWNER/PROTECT/HALFOP status commands
All checks were successful
CI / check (push) Successful in 3m47s

OWNER/DEOWNER (+q), PROTECT/DEPROTECT (+a, alias ADMIN), and
HALFOP/DEHALFOP (+h) set the higher channel-status modes. They reuse the
OP handler's target resolution and PEACE check; OWNER is founder-only,
the rest need op access.
This commit is contained in:
Jean Chevronnet 2026-07-15 18:40:19 +00:00
parent 30e91bb295
commit 6e3a758cc1
No known key found for this signature in database
3 changed files with 51 additions and 1 deletions

View file

@ -58,6 +58,7 @@ const TOPICS: &[HelpEntry] = &[
HelpEntry { cmd: "STATUS", summary: "show a user's access", detail: "Syntax: \x02STATUS <#channel> [nick]\x02\nShows a user's access level on a channel." },
HelpEntry { cmd: "OP/DEOP/VOICE/DEVOICE", summary: "give or take op/voice", detail: "Syntax: \x02OP|DEOP|VOICE|DEVOICE <#channel> [nick]\x02\nGives or takes channel op or voice." },
HelpEntry { cmd: "UP/DOWN", summary: "apply or drop your status", detail: "Syntax: \x02UP|DOWN <#channel>\x02\nUP re-applies the op/voice your access entitles you to; DOWN removes your status." },
HelpEntry { cmd: "OWNER/PROTECT/HALFOP", summary: "give or take higher status", detail: "Syntax: \x02OWNER|PROTECT|HALFOP <#channel> [nick]\x02 (and \x02DEOWNER|DEPROTECT|DEHALFOP\x02)\nSets +q/+a/+h. OWNER is founder-only; PROTECT and HALFOP need op access." },
HelpEntry { cmd: "KICK", summary: "kick from the channel", detail: "Syntax: \x02KICK <#channel> <nick> [reason]\x02\nKicks a user from the channel." },
HelpEntry { cmd: "BAN/UNBAN", summary: "ban or unban a user", detail: "Syntax: \x02BAN <#channel> <nick> [reason]\x02, \x02UNBAN <#channel> [nick]\x02\nBans or unbans a user by host." },
HelpEntry { cmd: "AKICK", summary: "manage the auto-kick list", detail: "Syntax: \x02AKICK <#channel> ADD <mask> [reason] | DEL <mask> | LIST | CLEAR\x02\nManages the auto-kick list; matches are banned and kicked on join. CLEAR empties it." },
@ -255,6 +256,12 @@ impl Service for ChanServ {
Some("DEVOICE") => op::handle(me, from, "-v", args, ctx, net, db),
Some("UP") => updown::handle(me, from, true, args, ctx, net, db),
Some("DOWN") => updown::handle(me, from, false, args, ctx, net, db),
Some("OWNER") => op::handle(me, from, "+q", args, ctx, net, db),
Some("DEOWNER") => op::handle(me, from, "-q", args, ctx, net, db),
Some("PROTECT") | Some("ADMIN") => op::handle(me, from, "+a", args, ctx, net, db),
Some("DEPROTECT") | Some("DEADMIN") => op::handle(me, from, "-a", args, ctx, net, db),
Some("HALFOP") => op::handle(me, from, "+h", args, ctx, net, db),
Some("DEHALFOP") => op::handle(me, from, "-h", args, ctx, net, db),
Some("KICK") => kick::handle(me, from, args, ctx, net, db),
Some("BAN") => ban::handle(me, from, args, ctx, net, db),
Some("UNBAN") => unban::handle(me, from, args, ctx, net, db),

View file

@ -9,7 +9,13 @@ pub fn handle(me: &str, from: &Sender, mode: &str, args: &[&str], ctx: &mut Serv
ctx.notice(me, from.uid, "Syntax: OP/DEOP/VOICE/DEVOICE <#channel> [nick]");
return;
};
if !super::require_op(me, from, chan, ctx, db) {
// Granting owner (+q) is founder-only; op/halfop/protect need op access.
let allowed = if mode.contains('q') {
super::require_founder(me, from, chan, ctx, db)
} else {
super::require_op(me, from, chan, ctx, db)
};
if !allowed {
return;
}
let target = match args.get(2) {