High-speed Telegram bot with two modes:
- Regular users: friendly "chat girl" style conversations in DM and groups.
- Sudo users: instant mass moderation commands (
/banall,!banall,/nukeall,!nukeall).
/startintroduces the chat persona (Sukoon).- Bot chats in private chats and in groups.
- By default, group reply mode is enabled (
CHATBOT_GROUP_REPLY_ALL=true). - Gemini is used for natural responses.
- Sukoon style is tuned for natural Indian Hinglish chat tone.
- If Gemini is slow/unavailable, Sukoon uses a local fallback reply so users still get responses.
- Gemini client now tries fallback models and API versions before local fallback.
- By default, chatbot is enabled for sudo users too (
CHATBOT_ALLOW_SUDO=true) so you can test from owner accounts.
Important for groups:
- Disable BotFather -> Group Privacy for your bot, otherwise Telegram will not deliver normal group messages to the bot.
/banallor!banall: delete command message (if possible), ban actionable members fast, leave group./nukeallor!nukeall: same as above + delete recent messages.- No second confirmation step.
main.py- app startup and handler registrationconfig.py- environment config + validationhandlers/- moderation/chat logicutils/- Gemini client, logging, guardsscripts/- VPS bootstrap, preflight, service install/update helpersdeploy/systemd/- systemd service template.github/workflows/ci.yml- GitHub CI (compile + tests)
- Create env file:
cp .env.example .env- Create venv + install deps:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt- Validate config:
python scripts/preflight.py- Run:
python main.py- Ensure secrets are not tracked (
.envis ignored by.gitignore). - Run tests:
pytest -q- Run quick compile check:
python -m compileall main.py handlers utils tests- Push branch; CI runs automatically via
.github/workflows/ci.yml.
git clone <your-repo-url> banall-bot
cd banall-botchmod +x scripts/*.sh
./scripts/bootstrap_vps.shcp .env.example .env
nano .envMandatory values:
API_IDAPI_HASHBOT_TOKENSUDO_USERSGEMINI_API_KEY(whenCHATBOT_ENABLED=true)
./scripts/install_systemd_service.sh banall-bot "$(pwd)" "$(whoami)"Note: deployment from /root/... is supported by default service settings.
sudo systemctl status banall-bot
sudo journalctl -u banall-bot -fAfter sending a few DM/group messages to the bot:
tail -n 120 logs/actions.log | grep GEMINI_REPLY_SUCCESS
tail -n 120 logs/actions.log | grep CHATBOT_LOCAL_FALLBACK_USED
tail -n 120 logs/errors.logGEMINI_REPLY_SUCCESSpresent = real API replies are working.- Frequent
CHATBOT_LOCAL_FALLBACK_USEDmeans Gemini is failing; check.envkey/model values anderrors.log.
After pushing new commits:
cd /path/to/banall-bot
./scripts/update_service.sh banall-botRecommended baseline in .env:
WORKERS=16MAX_CONCURRENT_OPERATIONS=25CHATBOT_GROUP_COOLDOWN_SECONDS=1.0to1.5CHATBOT_GROUP_REPLY_ALL=true
If Telegram flood limits occur, reduce MAX_CONCURRENT_OPERATIONS.
Production deps are in requirements.txt.
Test/dev deps are in requirements-dev.txt.
Use moderation commands only where you have authorization and in compliance with Telegram Terms and local law.