Add moderation system with deterministic detection and strike ladder

Deterministic-only detection (no LLM): word list with precompiled
leetspeak variation matching, text/image flood, wall of text, repeated
messages (Levenshtein similarity), mention flooding, link rate limiting
for new members, invite flooding, join/leave cycling detection.

Three-strike response ladder: warn + redact → temp mute → permanent ban.
Strikes expire after configurable period. Admin room notifications with
context cards. DMs over public callouts.

Admin commands: !mod warn/mute/unmute/ban/strikes/forgive/history/reload/
status/test. All require ADMIN_USERS membership.

Feature-flagged: disabled by default, set FEATURE_MODERATION=true to
enable. All thresholds configurable via env vars. New member grace
period with stricter thresholds. Word list hot-reload via !mod reload.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-03-11 17:49:35 -07:00
parent 56f69cd4b7
commit 996bb18566
5 changed files with 1420 additions and 3 deletions

View File

@@ -50,6 +50,34 @@ MISSING_EXCLUDE_USERS= # comma-separated user IDs to never list as missin
# ---- Encryption ----
QUOTE_ENCRYPTION_KEY= # Base64-encoded 32-byte AES-256 key (required for !quote)
# ---- Moderation (disabled by default) ----
FEATURE_MODERATION= # set to "true" to enable the moderation system
MOD_WORDLIST= # path to newline-delimited word list file
MOD_WORDLIST_VARIATIONS=true # check leetspeak/spaced variants
MOD_STRIKE_EXPIRY_DAYS=30 # strikes expire after N days
MOD_MUTE_DURATION_MINUTES=60 # temp mute duration on strike 2
MOD_MAX_STRIKES=3 # strikes before permanent ban
MOD_FLOOD_MESSAGE_COUNT=5 # messages within window = flood
MOD_FLOOD_MESSAGE_WINDOW_SECONDS=10
MOD_FLOOD_IMAGE_COUNT=3 # images/files within window = flood
MOD_FLOOD_IMAGE_WINDOW_SECONDS=30
MOD_MAX_MESSAGE_LENGTH=2000 # max chars per message (0 = disabled)
MOD_REPEAT_COUNT=3 # same message N times = strike
MOD_REPEAT_WINDOW_SECONDS=60
MOD_REPEAT_SIMILARITY_THRESHOLD=0.85
MOD_MENTION_MAX=5 # max unique @mentions per message
MOD_MENTION_FLOOD_COUNT=3
MOD_MENTION_FLOOD_WINDOW_SECONDS=30
MOD_LINK_RATE_NEW_MEMBER=3 # max links per window (new members only)
MOD_LINK_RATE_WINDOW_SECONDS=60
MOD_INVITE_MAX_PER_HOUR=5
MOD_JOIN_LEAVE_COUNT=3 # join/leave cycles = flag (no auto-strike)
MOD_JOIN_LEAVE_WINDOW_MINUTES=10
MOD_NEW_MEMBER_DAYS=14 # accounts newer than N days = stricter thresholds
MOD_NEW_MEMBER_FLOOD_MULTIPLIER=0.5
MOD_ADMIN_ROOM= # dedicated admin room for mod notifications
MOD_DM_ON_ACTION=true # DM users when action is taken
# ---- Rate Limits (per user per day) ----
RATELIMIT_WEATHER=5
RATELIMIT_TRANSLATE=20