A production-ready, self-hosted Telegram group moderation bot built specifically for crypto/Web3 communities. Combines the best features from 10+ analyzed open-source bots into a single, configurable solution.
- Pattern-based spam detection β 30+ crypto-specific spam patterns
- CAS integration β Combot Anti-Spam System checks against known spammer database
- Crypto scam detection β Wallet phishing, fake airdrops, seed phrase scams
- Crypto address spam β Detects unsolicited ETH/BTC/SOL/TRON addresses
- Phishing URL detection β Catches fake DEX, wallet, and DeFi sites
- Heuristic analysis β Excessive caps, emojis, repeated chars
- Math captcha β Solve a math problem to verify
- Button captcha β Tap the correct emoji
- Configurable timeout β Auto-kick if not solved in time
- Auto-restriction β New members can't post until verified
- Whitelist mode β Only approved domains allowed
- Blacklist mode β Block specific domains
- URL shortener blocking β bit.ly, tinyurl, etc. auto-blocked
- Telegram invite filtering β Block group invite links
- Admin-configurable β Add/remove domains via commands
- Rate limiting β Max messages per time window
- Duplicate detection β Blocks repeated identical messages
- Minimum interval β Prevents rapid-fire messages
- Configurable actions β Warn, mute, or ban
- Progressive warnings β 1st warn β 2nd mute β 3rd ban (configurable)
- Expiring warnings β Warnings auto-expire after 30 days
- Admin tracking β All warnings logged with reason and admin
- Self-check β Users can check their own warnings
- Database logging β Every moderation action recorded
- Channel logging β Optional Telegram channel for audit trail
- File logging β Application logs to data/sentinel.log
- Admin stats β View action statistics per chat
- Customizable messages β Template variables ({mention}, {group_name}, etc.)
- Auto-delete β Join/leave messages auto-deleted
- Scam warnings β Built-in "admins never DM first" warning
- Python 3.10+ (or Docker)
- A Telegram Bot Token from @BotFather
git clone <your-repo-url>
cd telegram-mod-bot
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txtcp .env.example .env
nano .env # or your editor of choiceRequired settings:
BOT_TOKEN=your_bot_token_here
OWNER_ID=your_telegram_user_idOptional but recommended:
LOG_CHANNEL_ID=-1001234567890 # Private channel for audit logs
ADMIN_IDS=123456789,987654321 # Additional admin IDs
CAS_ENABLED=true # Combot Anti-Spam checking# Development (polling mode)
python -m bot.main
# Or with Docker
docker-compose up -d- Add the bot to your Telegram group
- Promote it to admin with these permissions:
- β Delete messages
- β Ban users
- β Invite users (for captcha)
- β Restrict members
- β Pin messages (optional)
- Send
/helpin the group to verify it's working
| Command | Description |
|---|---|
/help |
Show all available commands |
/rules |
Show group rules |
/report |
Report a message (reply to it) |
/mywarns |
Check your warning count |
| Command | Description |
|---|---|
/ban [reason] |
Ban a user (reply or ID) |
/unban |
Unban a user |
/kick [reason] |
Kick a user (can rejoin) |
/mute [duration] |
Mute a user (e.g., /mute 1h) |
/unmute |
Unmute a user |
/warn [reason] |
Warn a user |
/warns |
Check a user's warnings |
/clearwarns |
Clear a user's warnings |
/purge [n] |
Delete last n messages |
| Command | Description |
|---|---|
/settings |
View current moderation settings |
/setcaptcha on|off |
Toggle captcha verification |
/setlinks on|off |
Toggle link filtering |
/addlink domain.com |
Add domain to whitelist |
/rmlink domain.com |
Remove domain from whitelist |
| Command | Description |
|---|---|
/stats |
View moderation statistics |
/auditlog |
View recent audit log entries |
| Variable | Required | Default | Description |
|---|---|---|---|
BOT_TOKEN |
β | β | Telegram bot token |
OWNER_ID |
β | β | Your Telegram user ID |
ADMIN_IDS |
β | β | Additional admin IDs (comma-separated) |
LOG_CHANNEL_ID |
β | β | Channel ID for audit logs |
DATABASE_URL |
β | SQLite | Database connection string |
CAS_ENABLED |
β | true |
Enable CAS spam checking |
WEBHOOK_URL |
β | β | Webhook URL (production) |
WEBHOOK_PORT |
β | 8443 |
Webhook port |
OPENAI_API_KEY |
β | β | OpenAI key for AI spam detection |
Copy config/default_config.yaml and customize for each group. Place configs in data/groups/<group_id>.yaml.
The following domains are whitelisted by default:
telegram.org,t.megithub.com,twitter.com,x.comsonic.game,soniclabs.comethereum.org,etherscan.iocoingecko.com,coinmarketcap.comdexscreener.com,defillama.com
Modify in /config/settings.py or via /addlink and /rmlink commands.
# Build image
docker build -t sentinel-bot .
# Run with docker-compose
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose downFor production, use webhook mode with a reverse proxy:
WEBHOOK_URL=https://your-domain.com
WEBHOOK_PORT=8443
WEBHOOK_PATH=/webhookNginx config example:
server {
listen 443 ssl;
server_name your-domain.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location /webhook {
proxy_pass http://localhost:8443;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}# Copy files to server
scp -r . user@server:/opt/sentinel-bot
# Create systemd service
sudo cat > /etc/systemd/system/sentinel-bot.service << 'EOF'
[Unit]
Description=SentinelBot Telegram Moderation
After=network.target
[Service]
Type=simple
User=sentinel
WorkingDirectory=/opt/sentinel-bot
ExecStart=/opt/sentinel-bot/.venv/bin/python -m bot.main
Restart=always
RestartSec=10
EnvironmentFile=/opt/sentinel-bot/.env
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable --now sentinel-bottelegram-mod-bot/
βββ bot/
β βββ main.py # Entry point, handler registration
β βββ handlers/
β β βββ commands.py # All slash commands
β β βββ moderation.py # Core message processing pipeline
β β βββ welcome.py # New member handling & captcha
β β βββ callbacks.py # Inline button handlers
β βββ filters/
β β βββ spam.py # Pattern-based spam detection
β β βββ crypto_scam.py # Crypto-specific scam detection
β β βββ links.py # URL/domain filtering
β β βββ flood.py # Flood/rate limit detection
β βββ services/
β β βββ cas.py # CAS integration
β β βββ captcha_generator.py # Captcha generation
β β βββ audit_log.py # Audit logging service
β βββ database/
β β βββ db.py # SQLite database layer
β βββ utils/
β βββ permissions.py # Admin/owner permission checks
β βββ helpers.py # Utility functions
βββ config/
β βββ settings.py # Configuration management
β βββ default_config.yaml # Per-group config template
βββ data/ # Runtime data (DB, logs)
βββ Dockerfile
βββ docker-compose.yml
βββ requirements.txt
βββ .env.example
Every group message flows through this pipeline:
Message β Admin Check (skip) β Verified Check β Flood β Spam β Scam β Links β β
Pass
β β β β β
Delete Mute Warn+Del Ban+Del Warn+Del
Edit bot/filters/spam.py β add patterns to SPAM_PATTERNS:
SPAM_PATTERNS = [
# Your custom patterns
(r"(?i)your_regex_pattern_here", "Description"),
...
]Edit bot/filters/crypto_scam.py β add to SCAM_PATTERNS:
SCAM_PATTERNS = [
(re.compile(r'your_pattern'), "scam_type", "Description"),
...
]Either edit config/settings.py or use commands:
/addlink sonic.game
/addlink soniclabs.com
/rmlink suspicious-site.xyz
This bot was designed by analyzing 10+ open-source Telegram moderation bots. See RESEARCH.md for the full analysis.
| Feature | SentinelBot | tg-spam | JoinCaptcha | Samurai | Origin |
|---|---|---|---|---|---|
| Anti-Spam | β | β | β | β | β |
| CAS Integration | β | β | β | β | β |
| Captcha | β | β | β | β | β |
| Crypto Scam Detection | β | β | β | β | Partial |
| Link Filter | β | β | β | β | β |
| Flood Protection | β | β | β | β | β |
| Warning System | β | β | β | β | β |
| Audit Log | β | β | β | β | β |
| Docker | β | β | β | β | β |
| Lightweight (<100MB RAM) | β | β | β | β (800MB) | β |
MIT β Use freely for your Web3 community.
Built with β€οΈ for the Web3 community.