Bot for S95 sport event system.
- 🤖 Telegram bot integration with aiogram 3.x
- 🔄 Two operation modes: Polling (development) and Webhook (production)
- 🗄️ PostgreSQL database support with asyncpg
- 🔐 Secure webhook implementation with nginx reverse proxy
- 📊 Statistics and personal data tracking
- 🌍 Multi-language support (Russian, English, Belarusian, Serbian)
- 🎯 QR code generation for S95 system
- Install dependencies:
pip install -r requirements.txt- Create
.envfile:
API_BOT_TOKEN=your_bot_token
DATABASE_URL=postgresql://user:password@localhost:5432/s95_dev- Run the bot:
python main.pysudo -u postgres pg_restore -d s95_dev deploy/backup.tar --no-privileges --no-owner -U postgrespip install -r tests/requirements.txt
pytest --cov-report=term-missing:skip-covered --cov=. tests/For html report:
pytest --cov-report=html --cov=. tests/Use the included script to verify webhook configuration:
cd deploy
./check_webhook.sh [bot_token]Or let it read token from .env file automatically.
┌─────────────┐ ┌──────────┐ ┌─────────┐
│ Telegram │──────▶│ Nginx │──────▶│ Bot │
│ API │◀──────│ (443) │◀──────│ (5000) │
└─────────────┘ └──────────┘ └─────────┘
│
▼
┌──────────┐
│PostgreSQL│
└──────────┘
- aiogram 3.x - Telegram Bot framework
- asyncpg - PostgreSQL async driver
- PostgreSQL - Database
- Nginx - Reverse proxy for webhook
If bot crashes in production mode:
# Run diagnostic script
./deploy/diagnose_production.shQuick fix:
- Edit
.envfile - Uncomment
PRODUCTION=1(ortrue) - Ensure
HOST=https://yourdomain.com(with protocol!) - Restart bot:
sudo systemctl restart s95-bot
Check webhook status:
curl https://api.telegram.org/bot<YOUR_TOKEN>/getWebhookInfoView bot logs:
sudo journalctl -u s95-bot -f- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
pytest - Submit a pull request
All rights reserved.