mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 08:32:41 +00:00
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:
@@ -621,6 +621,31 @@ CREATE TABLE IF NOT EXISTS api_cache (
|
||||
cached_at INTEGER DEFAULT (unixepoch())
|
||||
);
|
||||
|
||||
-- Moderation: strikes
|
||||
CREATE TABLE IF NOT EXISTS mod_strikes (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
issued_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
expires_at DATETIME NOT NULL,
|
||||
reason TEXT NOT NULL,
|
||||
issued_by TEXT NOT NULL,
|
||||
active BOOLEAN NOT NULL DEFAULT TRUE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_mod_strikes_user ON mod_strikes(user_id, issued_at);
|
||||
|
||||
-- Moderation: action log
|
||||
CREATE TABLE IF NOT EXISTS mod_actions (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
action TEXT NOT NULL,
|
||||
reason TEXT,
|
||||
taken_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
taken_by TEXT NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_mod_actions_user ON mod_actions(user_id, taken_at);
|
||||
|
||||
-- Space groups (rooms with overlapping membership)
|
||||
CREATE TABLE IF NOT EXISTS space_groups (
|
||||
room_id TEXT PRIMARY KEY,
|
||||
|
||||
1301
internal/plugin/moderation.go
Normal file
1301
internal/plugin/moderation.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user