Banish is a Telegram bot for democratic chat moderation. It allows community members to vote on banning or forgiving spammers through reactions, buttons, or commands.
- ✅ Three ways to start a ban:
/bancommand, bot mention, message reaction - ✅ Flexible voting: inline buttons or reactions with customizable emoji
- ✅ Admin panel: manage chat settings, view history
- ✅ Trusted users: protect active members and admins from bans
- ✅ Async processing: scalable with message queues
- ✅ Security: admins are immune from banning
Backend: PHP 8.3 • Symfony 6.4 • PostgreSQL 15 • RabbitMQ Frontend: Vue.js 3 • Vite • Vue Router Infrastructure: Docker • Nginx • Supervisor
Option 1: Command
Reply to spammer's message: /ban
Option 2: Bot Mention
Reply to spammer's message: @bot_name
Option 3: Reaction
Long-press message → Add reaction → Select ban emoji (default: 👎)
After ban procedure starts, members vote using:
Inline Buttons
- 🔨 Ban — vote for ban
- 🕊️ Forgive — vote for forgiveness
Reactions on Original Message
- Ban emoji (👎) = vote for ban
- Forgive emoji (👍) = vote for forgiveness
- Remove reaction = cancel vote
When required vote count is reached (configurable):
- Ban approved → User blocked, spam message deleted
- Forgive approved → Procedure cancelled, user remains in chat
| Command | Description | Access |
|---|---|---|
/help |
Bot help | Everyone |
/ban |
Start ban procedure | Everyone |
/admin |
Get admin panel link | Chat admins |
Access via /admin. Configure per-chat settings:
- Vote count required for ban
- Emoji for reactions
- Minimum messages for "trusted" user protection
- Delete spam message after ban
- Enable/disable voting by reactions
- Docker & Docker Compose
- 8+ vCPU, 16+ GB RAM (for production)
- Public domain with HTTPS
git clone [email protected]:BeMySlaveDarlin/banish.git
cd banishCopy appropriate compose file for your environment:
# For production
cp docker/docker-compose.prod.yaml docker-compose.override.yaml
# For development
cp docker/docker-compose.dev.yaml docker-compose.override.yamlOr use Docker's default override mechanism — it will automatically load docker-compose.override.yaml.
cp .env.example .envRequired .env parameters:
| Parameter | Description |
|---|---|
APP_ENV |
Environment: prod, dev, local, test |
APP_SECRET |
Webhook signature secret (random string) |
TELEGRAM_BOT_NAME |
Bot username without @ |
TELEGRAM_BOT_TOKEN |
Bot API token from BotFather |
DATABASE_PORTS |
PostgreSQL port (change from default) |
MEMCACHED_PORTS |
Memcached port (change from default) |
For production:
Place in var/ssl/:
server.crt— public certificateserver.key— private key
For development: Certificates are generated automatically on first build:
make # Automatically generates SSL for NGINX_BACKEND_DOMAINOr manually:
mkdir -p var/ssl
openssl req -x509 -newkey rsa:4096 -keyout var/ssl/server.key -out var/ssl/server.crt -days 365 -nodes -subj "/CN=${NGINX_BACKEND_DOMAIN:-localhost}"make # Full build and start
make down # Stop all services
make restart # Rebuild and restart
make db-migrate # Run migrations
make clear-cache # Clear cache1. Create Bot
- Talk to @BotFather
- Create new bot, get token
2. Set Webhook
curl "https://api.telegram.org/bot<TOKEN>/setWebhook?url=https://<DOMAIN>/api/telegram/webhook/<APP_SECRET>"Verify:
curl "https://api.telegram.org/bot<TOKEN>/getWebhookInfo"3. Add to Group
- Add bot as member with permissions:
- Read messages
- Send messages
- Delete messages
- Ban users
For reaction voting to work:
-
Enable Reactions
- Group Settings → Reactions → Enable
-
Bot Receives Updates
- Webhook has
message_reactioninallowed_updates
- Webhook has
-
Enable in Admin Panel
- Set
enableReactions: true(default)
- Set
In admin panel (/admin):
- Votes Required — votes to approve ban (default: 3)
- Ban Emoji — emoji for ban votes (default: 👎)
- Forgive Emoji — emoji for forgiveness (default: 👍)
- Min Messages for Trust — messages to protect user (default: 5)
- Delete Spam — remove spam message after ban (default: true)
- Enable Reactions — allow reaction voting (default: true)
Configure in database queue_schedule_rule table:
-- Every 6 hours
UPDATE queue_schedule_rule
SET rule = '0 */6 * * *'
WHERE schedule = 'clear_bot_messages';
-- Or use intervals (1 day, 7 days, etc)
UPDATE queue_schedule_rule
SET rule = '1 day'
WHERE schedule = 'clear_bot_messages';
-- Disable cleanup
DELETE
FROM queue_schedule_rule
WHERE schedule = 'clear_bot_messages';Reactions not creating ban:
- Verify reactions enabled in group settings
- Check webhook has
message_reactioninallowed_updates - View logs:
docker-compose logs app
Voting doesn't work:
- Verify correct emoji in admin panel
- Check chat enabled (
enabled: true) - Check vote count threshold
"Admin is immune" message:
- Expected — group admins cannot be banned
Webhook issues:
- Test:
curl "https://api.telegram.org/bot<TOKEN>/getWebhookInfo" - Verify domain DNS resolves
- Check HTTPS certificate is valid
Found a bug or have an idea?
- New features: Create PR
- Report issue: Create Issue