A Telegram moderation assistant that flags potentially hateful or toxic messages in group chats and lets an admin approve, edit, or ignore suggested replies. It uses OpenRouter for moderation classification and reply drafting, with per-group rate limits, random throttling, and admin controls.
- Flags messages and sends approvals to a single admin (no auto-replies).
- Per-group settings: enable/disable, notify-only mode, random chance, thresholds, mute.
- Built-in cooldowns: alert (10 min) and post (1 hour).
- SQLite storage for groups, pending approvals, and stats.
- Rust toolchain (edition 2021)
- Telegram bot token
- OpenRouter API key
- Create a
.envfile with:TG_BOT_TOKEN=... OPENROUTER_API_KEY=...
- Update
ADMIN_IDinsrc/main.rsto your Telegram user ID.
cargo run- Use
/panelin the bot DM to open the admin panel. - List groups to open settings directly.
- Pending approvals show a per-item detail view with Post/Edit/Ignore.
bot.sqliteis created in the repo root and holds state.src/main.rscontains all logic (handlers, DB, settings UI).
- The bot only processes group/supergroup messages.
- Random chance controls the percentage of flagged items that trigger admin alerts.
- Threshold controls the minimum classifier severity (0..1) required to flag.
- Rust provides memory safety in safe code; this project does not use
unsafe. - Keep
TG_BOT_TOKENandOPENROUTER_API_KEYprivate (use.env, avoid committing). - Protect
bot.sqlitewith appropriate file permissions; it contains moderation history. - Run a single bot instance per token to avoid polling conflicts.
This bot is dedicated to TC and his constant battle to fight hatred and bigotry online.