BotServ: KICK <#channel> TEST <message> dry-run
Reports which content kicker (caps/formatting/badwords) a line would trip, without kicking anyone — so an op can tune caps% or a badword regex safely. Reuses the typed KickerSettings::violation() and the shared badword-set builder (moved to db so the test and the live path share it).
This commit is contained in:
parent
9f5f0ed0d2
commit
0edc4d4e87
4 changed files with 60 additions and 12 deletions
|
|
@ -25,6 +25,21 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db:
|
|||
return;
|
||||
}
|
||||
|
||||
// TEST dry-runs the content kickers against a line, kicking nobody — so an
|
||||
// op can tune caps%/badword patterns safely.
|
||||
if kind.eq_ignore_ascii_case("TEST") {
|
||||
if args.len() < 4 {
|
||||
ctx.notice(me, from.uid, "Syntax: KICK <#channel> TEST <message>");
|
||||
return;
|
||||
}
|
||||
let text = args[3..].join(" ");
|
||||
match db.kicker_test(chan, &text) {
|
||||
Some(reason) => ctx.notice(me, from.uid, format!("That line \x02would be kicked\x02: {reason}")),
|
||||
None => ctx.notice(me, from.uid, "That line trips no content kicker (flood/repeat depend on timing and repetition, so they aren't tested here)."),
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let on = match args.get(3).map(|s| s.to_ascii_uppercase()).as_deref() {
|
||||
Some("ON") | Some("TRUE") => true,
|
||||
Some("OFF") | Some("FALSE") => false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue