CLI for managing Telegram bots via TG Runner
Project description
🤖 TG Runner CLI
✨ Возможности
- 🚀 Три режима деплоя: код, Docker, Git
- 📊 Полное управление: start, stop, logs, status
- 🔒 Изоляция: каждый бот в Docker-контейнере
- 🎨 Красивый UI: цветной вывод с Rich
📦 Установка
pip install tg-runner-cli
🚀 Быстрый старт
1. Настройка
export TG_RUNNER_URL=http://your-orchestrator:8000
export TG_RUNNER_TOKEN=your-token
2. Запуск бота
# Простой бот из файла
tg-runner start my-bot --simple bot.py \
-r "aiogram>=3.0" \
-e "BOT_TOKEN=123:ABC..."
# Из Git репозитория
tg-runner start my-bot --git https://github.com/user/bot.git \
-e "BOT_TOKEN=123:ABC..."
3. Управление
tg-runner list # Список ботов
tg-runner status my-bot # Статус
tg-runner logs my-bot # Логи
tg-runner stop my-bot # Остановка
📋 Команды
| Команда | Описание |
|---|---|
start |
Запустить бота |
stop |
Остановить бота |
update |
Обновить код бота |
restart |
Перезапустить |
list |
Список всех ботов |
status |
Статус бота |
logs |
Логи бота |
🎯 Режимы деплоя
1️⃣ Simple — Код напрямую
# Один файл
tg-runner start bot --simple bot.py -r "aiogram>=3.0"
# Несколько файлов
tg-runner start bot --simple main.py handlers.py -r "aiogram,aiohttp"
# Inline код
tg-runner start bot --simple --inline --code 'print("Hello")'
2️⃣ Custom — Dockerfile/Git
# Из директории с Dockerfile
tg-runner start bot --custom ./my-project/
# Из Git репозитория
tg-runner start bot --git https://github.com/user/bot.git --branch main
3️⃣ Image — Готовый Docker-образ
tg-runner start bot --image ghcr.io/user/my-bot:v1.0
# С авторизацией
tg-runner start bot --image registry.com/bot:latest \
--registry-user user --registry-pass token
📝 Пример бота
bot.py:
import asyncio, os
from aiogram import Bot, Dispatcher, types
from aiogram.filters import Command
bot = Bot(token=os.environ["BOT_TOKEN"])
dp = Dispatcher()
@dp.message(Command("start"))
async def start(message: types.Message):
await message.answer("Привет! 👋")
@dp.message()
async def echo(message: types.Message):
await message.answer(message.text)
asyncio.run(dp.start_polling(bot))
Запуск:
tg-runner start echo-bot --simple bot.py \
-r "aiogram>=3.0" \
-e "BOT_TOKEN=123:ABC..."
⚙️ Конфигурация
| Переменная | Описание |
|---|---|
TG_RUNNER_URL |
URL оркестратора |
TG_RUNNER_TOKEN |
Токен клиента |
Или через флаги:
tg-runner --url http://localhost:8000 --token mytoken start ...
🔗 Экосистема TG Runner
| Компонент | Описание |
|---|---|
| tg-runner-orchestrator | Orchestrator |
| tg-runner-worker | Worker |
| tg-runner-cli | CLI (этот репо) |
🔒 Лимиты
| Параметр | Значение |
|---|---|
| Макс. ботов | 3 |
| Время работы | 24 часа |
| RAM | 256 MB |
| CPU | 0.5 cores |
📄 Лицензия
MIT License
Made with ❤️ by TimaxLacs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tg_runner_cli-1.0.0.tar.gz
(14.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tg_runner_cli-1.0.0.tar.gz.
File metadata
- Download URL: tg_runner_cli-1.0.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b369a5f883dbea3b727637bcd2ec6d63b26a49a93637e80f3442b2a88a47dff5
|
|
| MD5 |
966812ea17e5685336a847fc993aebd0
|
|
| BLAKE2b-256 |
b4c4b78975b09a164291d8fb23cadecf31936db282a985811019eeb0f61a9c6f
|
File details
Details for the file tg_runner_cli-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tg_runner_cli-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f46b5e1f99b07e020f44de4dfd394c986c11279b38763020326ac6131cfd8cb2
|
|
| MD5 |
db5acb95835749a1a92217b22654a3d3
|
|
| BLAKE2b-256 |
81e69dd2f1a737ee51e821b26fec7be300cebea330a14785198fd3554729f686
|