Skip to content

About

๐Ÿš€ Run multiple Telegram bots in one instance with auto-recovery, process isolation, custom environments, and a live web dashboard.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

36 Commits

Folders and files

Repository files navigation

๐ŸŽ“ BotClusters v8.1

Maintainer: Goutham Josh
Original Developer / Contributor: MysteryDemon

Have you encountered the problem where you have to host resource-efficient Telegram Bots for free and you can only host a bot per account, but you wanted to host multiple bots in one instance? Say no more...

BotClusters lets you run multiple bots in the same instance. Built with process isolation, supervisord auto-recovery, dynamic virtual environments, and a live web dashboard.


๐Ÿ”ฐ Repo Features

  • ๐Ÿค– Web GUI Bot Manager: Add, configure, edit, clone, and delete bot clusters directly from the dashboard without editing config files
  • ๐Ÿ“Š Real-Time Resource Metrics: Live gauges for CPU load %, host RAM usage (MB / %), and Disk space
  • โšก Per-Process Telemetry: Track memory consumption (RSS MB), CPU %, uptime, and PID for each bot individually
  • ๐ŸŽ›๏ธ Batch Cluster Operations: One-click "Start All", "Stop All", and "Restart All" cluster management
  • ๐Ÿ’ป Integrated Bot Console / Terminal: Execute diagnostic shell commands (pip list, git status, python -c ...) inside any bot directory
  • โฌ‡๏ธ One-Click Git Pull & Reload: Pull latest commits from bot repositories on demand without full server rebuilds
  • ๐Ÿ“ข Telegram Crash Alerts: Instant Telegram notifications if a bot repeatedly crashes or enters auto-pause
  • ๐Ÿ’พ Cluster Backup & Restore: Export all bot definitions and environment settings to JSON and restore anytime
  • ๐Ÿ“œ Advanced Log Streaming: Real-time SSE log stream with process filtering, STDOUT/STDERR isolation, live search, and file export
  • ๐Ÿ”„ Auto Updates: Optional automatic updates through GitHub on restart
  • ๐Ÿ›ก๏ธ Reliable Process Management: Powered by supervisord with automated process supervision and smart auto-pause recovery
  • ๐Ÿ” Environment Control: Configure key-value environment variables per bot directly in the visual editor
  • ๐ŸŽฎ Custom Execution: Configure custom entry scripts (bot.py, main.py, app.py, start.sh)
  • ๐Ÿ”’ Private Repo Support: Clone and run bots from private repositories using GitHub tokens
  • ๐ŸŽ›๏ธ Cloud & Cross-Platform Integration: Ready for Render, Koyeb, Heroku, Docker, Codespaces, and standalone local environments
  • ๐Ÿ Multi-Python Support: Supports specific Python versions (3.10 to 3.13, as installed in the Docker image)
  • ๐ŸŸฉ Node.js Support: Run Node.js bots (node:20, node:22, node:latest) with automatic npm install

๐Ÿš€ Quick Start

  1. Fork and Star this repository
  2. Configure your bots in cluster.env
  3. Deploy to your preferred platform using the buttons below

#๏ธโƒฃ Sample Var.CLUSTERS

Config Description Required
botname Unique name for your bot โœ…
git_url Git repository URL โœ…
branch Repository branch name โœ…
run_command Bot execution command (bot.py, main.py, start.sh) โœ…
env Environment variables dictionary โŒ
runtime_version Python version (3.10โ€“3.13) or Node.js (node:20, node:22, node:latest) โŒ
cron Auto-restart cron schedule, e.g. 0 */6 * * * (7th item; use null as 6th item to skip the version; or set it in the bot form) โŒ

โœ… Supported Python Versions

python3.10 โ€ข python3.11 โ€ข python3.12 โ€ข python3.13


๐Ÿ› ๏ธ Setup Guide

  • Format:
["botname", "git_url", "branch", "run_command", {ENV_DICT}, "runtime_version", "cron"]
  • For Public Repositories:
["bot01", "https://github.com/exampleuser/bot.git", "main", "bot.py", {"PORT": "8787"}]
  • For Private Repositories:
["bot02", "https://<your_username>:<your_github_token>@github.com/<your_username>/privatebot.git", "main", "main.py", {"PORT": "6060"}]
  • For Custom Python Version:
["bot03", "https://github.com/exampleuser/legacybot.git", "main", "main.py", {"PORT": "6060"}, "3.11"]
  • For Node.js Bots:
["bot04", "https://github.com/exampleuser/nodebot.git", "main", "index.js", {"BOT_TOKEN": "123:ABC"}, "node:22"]
  • For Module Entry Points (python -m):
["bot05", "https://github.com/exampleuser/pkgbot.git", "main", "-m mypkg.main", {}]

โšก Deploy

Open in GitHub Codespaces

Deploy to Koyeb

Deploy to Render

Deploy to Heroku


๐Ÿ’ป Testing in GitHub Codespaces

  1. Launch a Codespace on this repository (Code > Codespaces > Create codespace on main).
  2. Configure your bot in cluster.env:
    cp cluster.env.sample cluster.env
    nano cluster.env
  3. Build and test using Docker:
    docker build -t botclusters .
    docker run -p 5000:5000 --env-file cluster.env botclusters
  4. Open Dashboard: Codespaces will automatically detect port 5000 and prompt you to Open in Browser. Log in with admin / password123.

๐Ÿ”ง Latest fixes

  • Pull, webhook, auto-pull and rollback no longer start a bot you stopped - they restart only bots that are RUNNING.
  • Dependencies now reinstall when requirements.txt / package.json changes, also at boot after an auto-update (hash stamp inside venv/ or node_modules/).
  • Node.js bots: pull / rollback re-run npm install when package.json changes.
  • Dotted module run commands (pkg.sub.main) are no longer cut to pkg.
  • Settings save is all-or-nothing: an invalid value no longer leaves earlier fields half-saved.
  • Graceful shutdown no longer crashes on a changing process list; stale Installingโ€ฆ badges clear at boot immediately.

๐Ÿ†• What changed in 8.1 (bug-fix release)

  • Live dashboard updates work again (broadcast= socket error fixed).
  • Bots no longer vanish / show STOPPED when one bot is down (supervisorctl status exit code 3).
  • worker.py now uses the same names/paths as the dashboard (no random name prefix), sets up ALL CLUSTER_xx (not only 30), and one bad repo no longer blocks the rest.
  • update.py no longer deletes/overwrites cluster.env.
  • Random per-install session secret, login lockout, constant-time password check.
  • Clone / pip install runs in background with an Installingโ€ฆ / Setup failed card state.
  • Per-bot cron restart now really works; global schedule only restarts bots that are running.
  • Crash alerts (Telegram) fire even with no browser open; real CPU %; container-aware RAM gauge.
  • Reserved bot names (app, bots, โ€ฆ) blocked - they could wipe dashboard files.

โœจ New in 8.1 (features)

  • ๐Ÿ“ˆ RAM sparkline + restart counter on every bot card (spot crash loops / memory leaks).
  • โช Versions: last commits per bot, one-click rollback (and roll forward).
  • ๐Ÿ”— GitHub webhook auto-deploy: copy the per-bot URL from Versions into GitHub โ†’ Webhooks (push). Push = pull + restart.
  • โฌ‡ Auto-pull schedule (Settings โ†’ minutes): restarts a running bot only when its repo has new commits.
  • ๐Ÿ‘ Secret-masked env editor: tokens/keys/passwords hidden until you click the eye.
  • โง‰ Clone bot: copy a bot's settings into a new one.

๐Ÿ“ Notes

  • Bots can be Python, Node.js, or bash scripts.
  • It is not compulsory to set a Python version; only set it if your bot specifically requires an older/newer interpreter.
  • Keep your tokens and sensitive information secure in cluster.env. Never commit a real cluster.env - add it to .gitignore.
  • If your bot needs additional system or pip packages, define them in install.sh.
  • GUI login details (configurable via ADMIN_USERNAME and ADMIN_PASSWORD):
    • Default admin / password123 - change it in Settings right after first login (dashboard warns you).

๐Ÿ‘ฅ Credits & Contributors


๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

๐Ÿš€ Run multiple Telegram bots in one instance with auto-recovery, process isolation, custom environments, and a live web dashboard.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages