From dacadebd281587d585893d74e9020b156ad48170 Mon Sep 17 00:00:00 2001 From: hoshimach1 Date: Sun, 11 Jan 2026 07:14:22 +0300 Subject: [PATCH] Added docker and readme --- README.md | 95 +++++++++++++++++++++++++++++++++++++++ docker/Dockerfile | 15 +++++++ docker/docker-compose.yml | 16 +++++++ 3 files changed, 126 insertions(+) create mode 100644 README.md create mode 100644 docker/Dockerfile create mode 100644 docker/docker-compose.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..498df9b --- /dev/null +++ b/README.md @@ -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 + 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. diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..a456cb0 --- /dev/null +++ b/docker/Dockerfile @@ -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"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..6e2ea4e --- /dev/null +++ b/docker/docker-compose.yml @@ -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"