mirror of
https://github.com/anten-ka/gotelegram_pro.git
synced 2026-05-19 13:26:02 +00:00
v2.2.1: unified menu with bot management, grouped sections, telemt download fix, QR cleanup, version bump
This commit is contained in:
@@ -1,70 +1,147 @@
|
||||
# GoTelegram MTProxy Bot
|
||||
|
||||
Telegram-бот для управления MTProxy на сервере — те же функции, что и у CLI `gotelegram`, но через бота.
|
||||
|
||||
## Команды
|
||||
|
||||
| Команда | Описание |
|
||||
|--------|----------|
|
||||
| `/start`, `/help` | Справка |
|
||||
| `/install` | Установить или обновить прокси (выбор домена и порта) |
|
||||
| `/status` | Статус и данные подключения (IP, порт, secret, ссылка) |
|
||||
| `/link` | Только ссылка `tg://proxy` |
|
||||
| `/restart` | Перезапустить контейнер |
|
||||
| `/logs` | Последние логи контейнера |
|
||||
| `/remove` | Удалить прокси |
|
||||
| `/promo` | Промо хостинга |
|
||||
|
||||
## Установка на сервер
|
||||
|
||||
### Публичный репозиторий (одной командой)
|
||||
|
||||
```bash
|
||||
curl -sL https://raw.githubusercontent.com/anten-ka/gotelegram_pro/main/install_gotelegram_bot.sh -o /tmp/install_gotelegram_bot.sh && sudo bash /tmp/install_gotelegram_bot.sh
|
||||
```
|
||||
|
||||
При установке скрипт запросит **BOT_TOKEN** (получить у [@BotFather](https://t.me/BotFather)).
|
||||
|
||||
### Закрытый репозиторий (установка по ключу)
|
||||
|
||||
Для **приватного** репо используется клонирование по **SSH-ключу** или по **токену (PAT)**. Подробно: **[INSTALL_PRIVATE.md](../INSTALL_PRIVATE.md)** в корне репозитория.
|
||||
|
||||
Кратко:
|
||||
- **По SSH:** скопируйте `bootstrap_install.sh` на сервер, затем
|
||||
`GIT_REPO_SSH=git@github.com:USER/REPO.git sudo bash bootstrap_install.sh`
|
||||
- **По токену:**
|
||||
`GITHUB_TOKEN=ghp_xxx GIT_REPO_HTTPS=https://github.com/USER/REPO.git sudo -E bash bootstrap_install.sh`
|
||||
- Или клонируйте репо вручную и запустите:
|
||||
`sudo ./install_gotelegram_bot.sh`
|
||||
|
||||
### Локально (файлы уже рядом со скриптом)
|
||||
|
||||
```bash
|
||||
sudo ./install_gotelegram_bot.sh
|
||||
```
|
||||
|
||||
## Конфигурация
|
||||
|
||||
Файл: `/opt/gotelegram-bot/.env`
|
||||
|
||||
- **BOT_TOKEN** — токен от @BotFather (обязательно).
|
||||
- **ALLOWED_IDS** — опционально. Список ID пользователей через запятую; если не задан, бот доступен всем.
|
||||
|
||||
После изменения `.env` перезапуск сервиса:
|
||||
|
||||
```bash
|
||||
sudo systemctl restart gotelegram-bot
|
||||
```
|
||||
|
||||
## Требования на сервере
|
||||
|
||||
- Linux (systemd), Docker, Python 3.
|
||||
- Перед использованием бота на сервере должен быть установлен Docker (бот сам поднимает контейнер `nineseconds/mtg:2` по команде `/install`).
|
||||
|
||||
## Управление сервисом
|
||||
|
||||
```bash
|
||||
sudo systemctl status gotelegram-bot
|
||||
sudo systemctl restart gotelegram-bot
|
||||
journalctl -u gotelegram-bot -f
|
||||
```
|
||||
# GoTelegram v2.2 Bot
|
||||
|
||||
Production-quality Telegram bot for managing MTProxy (telemt engine) on Linux servers.
|
||||
|
||||
## Features
|
||||
|
||||
- **Complete CLI Feature Parity** - All menu items from CLI version
|
||||
- Install (Quick/Stealth modes)
|
||||
- Status monitoring
|
||||
- Proxy link generation
|
||||
- Share with QR codes
|
||||
- Service restart
|
||||
- Logs viewing
|
||||
- Mode/template changes
|
||||
- Backup/restore
|
||||
- telemt updates
|
||||
- Website/SSL management
|
||||
- Remove installation
|
||||
- Promotional links
|
||||
|
||||
- **Template Browsing** - Browse categories → templates → preview → install
|
||||
- **V1 Migration** - Detects old mtg Docker container and offers migration
|
||||
- **Access Control** - ALLOWED_IDS from .env
|
||||
- **Async/Await** - Full async support via python-telegram-bot v21+
|
||||
- **Inline Keyboards** - Modern UI with callback-based navigation
|
||||
- **Shell Integration** - Executes system commands via asyncio subprocess
|
||||
- **Error Handling** - Production-ready error handling
|
||||
|
||||
## Installation
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Python 3.8+
|
||||
- Linux system with systemd
|
||||
- telemt installed and running
|
||||
- Telegram Bot Token from @BotFather
|
||||
|
||||
### Setup
|
||||
|
||||
1. Install dependencies:
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
2. Create .env file:
|
||||
```bash
|
||||
cp config.example.env .env
|
||||
# Edit .env and set your BOT_TOKEN
|
||||
nano .env
|
||||
```
|
||||
|
||||
3. (Optional) Restrict access to specific users:
|
||||
```bash
|
||||
# Edit .env and uncomment ALLOWED_IDS
|
||||
# ALLOWED_IDS=123456789,987654321
|
||||
```
|
||||
|
||||
### Running the Bot
|
||||
|
||||
```bash
|
||||
python3 bot.py
|
||||
```
|
||||
|
||||
For systemd service:
|
||||
|
||||
```bash
|
||||
[Unit]
|
||||
Description=GoTelegram Bot
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=gotelegram
|
||||
WorkingDirectory=/opt/gotelegram/bot
|
||||
ExecStart=/usr/bin/python3 /opt/gotelegram/bot/bot.py
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### .env Variables
|
||||
|
||||
- `BOT_TOKEN` - Telegram bot token (required)
|
||||
- `ALLOWED_IDS` - Comma-separated user IDs (optional, all users allowed if empty)
|
||||
|
||||
### System Paths
|
||||
|
||||
- `GOTELEGRAM_CONFIG` - `/opt/gotelegram/config.json`
|
||||
- `TELEMT_CONFIG` - `/etc/telemt/config.toml`
|
||||
- `TELEMT_SERVICE` - `telemt` (systemd service name)
|
||||
- `WEBSITE_ROOT` - `/var/www/gotelegram-site`
|
||||
- `BACKUP_DIR` - `/opt/gotelegram/backups`
|
||||
- `TEMPLATES_CATALOG` - `/opt/gotelegram/templates_catalog.json`
|
||||
|
||||
## Architecture
|
||||
|
||||
### Single File Design
|
||||
All functionality in one `bot.py` for simplicity and ease of deployment.
|
||||
|
||||
### Command Handlers
|
||||
- `/start` - Main menu
|
||||
- `/help` - Help text
|
||||
- `/status` - Quick status
|
||||
- `/logs` - Recent logs
|
||||
|
||||
### Callback Handlers
|
||||
Organized by feature:
|
||||
- Installation (quick/stealth modes)
|
||||
- Status monitoring
|
||||
- Backup/restore
|
||||
- SSL management
|
||||
- Updates
|
||||
- Removal
|
||||
|
||||
### Shell Integration
|
||||
Async subprocess wrapper:
|
||||
```python
|
||||
code, stdout, stderr = await sh("command", "arg1", "arg2")
|
||||
```
|
||||
|
||||
## Callback Data Convention
|
||||
|
||||
- `menu_*` - Menu items
|
||||
- `install_mode_*` - Install options
|
||||
- `quick_dom_*` - Domain selection
|
||||
- `stealth_cat_*` - Template categories
|
||||
- `stealth_tpl_*` - Template selection
|
||||
- `stealth_confirm_*` - Confirm installation
|
||||
- `backup_*` - Backup operations
|
||||
- `ssl_*` - SSL operations
|
||||
- `restore_backup_*` - Restore operations
|
||||
|
||||
## Credits
|
||||
|
||||
- **telemt** - MTProxy engine foundation
|
||||
- **HTML5UP** - Beautiful web templates
|
||||
- **Learning Zone** - Educational resources
|
||||
- **Start Bootstrap** - Bootstrap framework
|
||||
- **Community** - Your feedback and support
|
||||
|
||||
## License
|
||||
|
||||
GoTelegram v2.2 - Open source community project
|
||||
|
||||
Reference in New Issue
Block a user