BotServ BADWORDS: user-configurable regex kicker

BADWORDS <#channel> ADD|DEL|LIST|CLEAR manages a channel's badword
patterns, each a regular expression, so a channel matches whatever it
wants — an improvement over Anope's fixed ANY/SINGLE/START/END. Enable
with KICK <#channel> BADWORDS ON.

Uses the regex crate: it's finite-automata based with linear-time
matching, so untrusted user patterns can't cause catastrophic
backtracking (ReDoS). A channel's patterns compile into one RegexSet
(single-pass match against all of them), cached in the engine and rebuilt
only when the list's revision changes — so the hot path is one is_match
call, no per-message compilation or allocation. Patterns are validated
(and size-limited) at add time; matching is case-insensitive by default.
This commit is contained in:
Jean Chevronnet 2026-07-13 16:16:44 +00:00
parent 43def8ee23
commit ca95184359
No known key found for this signature in database
9 changed files with 238 additions and 7 deletions

View file

@ -66,6 +66,7 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db:
"UNDERLINES" => Kicker::Underlines,
"REVERSES" => Kicker::Reverses,
"ITALICS" => Kicker::Italics,
"BADWORDS" => Kicker::Badwords,
"DONTKICKOPS" => Kicker::DontKickOps,
other => {
ctx.notice(me, from.uid, format!("Unknown kicker \x02{other}\x02. Try CAPS, FLOOD, REPEAT, BOLDS, COLORS, UNDERLINES, REVERSES, ITALICS or DONTKICKOPS."));
@ -85,6 +86,7 @@ fn label(kicker: Kicker) -> &'static str {
Kicker::Italics => "italics",
Kicker::Flood => "flood",
Kicker::Repeat => "repeat",
Kicker::Badwords => "badwords",
Kicker::DontKickOps => "dontkickops",
}
}