2.8 KiB
2.8 KiB
Marzban Telegram Bot
A powerful Telegram Bot with a built-in Web App (Mini App) for managing Marzban VPN subscriptions.
Features
- 📱 Interactive Web App: A beautiful Material 3 Expressive UI for users to manage their VPN.
- 🌍 Localization: Fully localized in English and Russian.
- 📊 User Dashboard: Real-time traffic usage, expiration date, and subscription status.
- 🛍️ Shop: Integrated store to purchase VPN plans (Lite, Medium, Heavy, Unlimited) using Telegram Stars.
- 🎟️ Promo Codes: Advanced promo code system (discounts, bonus days, unlimited usage).
- 🔧 Configuration: Easy setup for users with QR codes and subscription links (VLESS/VMess/Trojan).
- 🛡️ Admin Panel: comprehensive admin tools directly in the Web App:
- View bot and server statistics (CPU, RAM, Revenue).
- Manage users (add days, reset traffic, ban/unban, delete).
- Create and manage promo codes.
- Broadcast messages to all users.
Tech Stack
- Backend: Python 3.11, Aiogram 3.x, FastAPI
- Database: SQLite (default) or PostgreSQL (via asyncpg)
- Frontend: HTML5, CSS3 (Material 3 Expressive Design), Vanilla JS
- Integration: Marzban API
Prerequisites
- A running Marzban instance.
- Telegram Bot Token (from @BotFather).
- Python 3.11+ (for local run) or Docker.
Setup & Configuration
-
Clone the repository:
git clone <your-repo-url> cd marzban_tg_bot -
Create config file: Rename
.env.exampleto.envand fill in the values:BOT_TOKEN=your_bot_token_here ADMIN_IDS=12345678,87654321 # Marzban Credentials MARZBAN_URL=https://your-marzban-domain.com MARZBAN_USERNAME=admin MARZBAN_PASSWORD=admin_password # Web App Settings BASE_URL=https://your-marzban-domain.com WEB_APP_URL=https://your-bot-domain.com # URL where this bot is hosted WEB_APP_PORT=8888 # Database (leave empty for SQLite) DATABASE_URL=
Running with Docker (Recommended)
-
Build and Run:
docker-compose -f docker/docker-compose.yml up -d --build -
Check Logs:
docker-compose -f docker/docker-compose.yml logs -f
The Web App will be available at http://your-server-ip:8888. Ensure you have set up a reverse proxy (Nginx/Caddy) with SSL pointing to this port, as Telegram Web Apps require HTTPS.
Running Locally
-
Create Virtual Environment:
python -m venv .venv source .venv/bin/activate # Linux/Mac .venv\Scripts\activate # Windows -
Install Dependencies:
pip install -r requirements.txt -
Run:
python main.py