BotServ: community !votekick / !voteban

SET <#channel> VOTEKICK <n> enables in-channel voting: members type
!votekick <nick> (or !voteban), each voter counts once, and when n votes
are reached within the window the assigned bot kicks (or bans then kicks)
the target. Votes are ephemeral and lapse after two minutes. Crowd
moderation with no op online.
This commit is contained in:
Jean Chevronnet 2026-07-13 19:32:25 +00:00
parent 374748b1f9
commit ad61addb84
No known key found for this signature in database
4 changed files with 122 additions and 11 deletions

View file

@ -42,6 +42,19 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db:
return;
}
// VOTEKICK takes a vote count (0 = off), not ON/OFF.
if option.eq_ignore_ascii_case("VOTEKICK") {
match args.get(3).and_then(|s| s.parse::<u16>().ok()) {
Some(n) => match db.set_votekick(chan, n) {
Ok(()) if n == 0 => ctx.notice(me, from.uid, format!("\x02!votekick\x02 is now disabled in \x02{chan}\x02.")),
Ok(()) => ctx.notice(me, from.uid, format!("\x02{n}\x02 vote(s) will now carry a \x02!votekick\x02/\x02!voteban\x02 in \x02{chan}\x02.")),
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),
},
None => ctx.notice(me, from.uid, "Syntax: SET <#channel> VOTEKICK <number> (0 to disable)"),
}
return;
}
// BANEXPIRE takes a duration, not ON/OFF.
if option.eq_ignore_ascii_case("BANEXPIRE") {
let Some(&arg) = args.get(3) else {