Added docker and readme

This commit is contained in:
2026-01-11 07:14:22 +03:00
parent 2b68dbac20
commit dacadebd28
3 changed files with 126 additions and 0 deletions

95
README.md Normal file
View File

@@ -0,0 +1,95 @@
# Marzban Telegram Bot
A powerful Telegram Bot with a built-in Web App (Mini App) for managing [Marzban](https://github.com/Gozargah/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](https://github.com/aiogram/aiogram), [FastAPI](https://fastapi.tiangolo.com/)
- **Database**: SQLite (default) or PostgreSQL (via asyncpg)
- **Frontend**: HTML5, CSS3 (Material 3 Expressive Design), Vanilla JS
- **Integration**: Marzban API
## Prerequisites
- A running [Marzban](https://github.com/Gozargah/Marzban) instance.
- Telegram Bot Token (from [@BotFather](https://t.me/BotFather)).
- Python 3.11+ (for local run) or Docker.
## Setup & Configuration
1. **Clone the repository:**
```bash
git clone <your-repo-url>
cd marzban_tg_bot
```
2. **Create config file:**
Rename `.env.example` to `.env` and fill in the values:
```ini
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)
1. **Build and Run:**
```bash
docker-compose -f docker/docker-compose.yml up -d --build
```
2. **Check Logs:**
```bash
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
1. **Create Virtual Environment:**
```bash
python -m venv .venv
source .venv/bin/activate # Linux/Mac
.venv\Scripts\activate # Windows
```
2. **Install Dependencies:**
```bash
pip install -r requirements.txt
```
3. **Run:**
```bash
python main.py
```
## License
MIT License.

15
docker/Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "main.py"]

16
docker/docker-compose.yml Normal file
View File

@@ -0,0 +1,16 @@
version: '3.8'
services:
bot:
build:
context: ..
dockerfile: docker/Dockerfile
container_name: marzban_bot
restart: unless-stopped
volumes:
- ../:/app
- ../bot.db:/app/bot.db
env_file:
- ../.env
ports:
- "8888:8888"