Add referral system and user balance tracking

Introduce balance field to User model with Alembic migration. Add
referral menu, admin /refpay command, and deep link sharing. Update
Dockerfile to multi-stage build and add Postgres service to compose.
Fix deep link parsing logic and conditional proxy initialization.
This commit is contained in:
2026-04-10 22:20:53 +07:00
parent 60de871e0c
commit 0ed0ad2b92
17 changed files with 337 additions and 80 deletions

View File

@@ -1,14 +1,46 @@
services:
postgres:
image: postgres:16-alpine
container_name: maleniabot_db
environment:
POSTGRES_USER: ${POSTGRES_USER:-malenia}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-malenia_password}
POSTGRES_DB: ${POSTGRES_DB:-malenia_db}
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test:
[
"CMD-SHELL",
"pg_isready -U ${POSTGRES_USER:-malenia} -d ${POSTGRES_DB:-malenia_db}",
]
interval: 5s
timeout: 10s
retries: 5
bot:
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/app
env_file:
- .env
container_name: maleniabot_app
depends_on:
postgres:
condition: service_healthy
environment:
BOT_TOKEN: ${BOT_TOKEN}
POSTGRES_URL: postgresql+asyncpg://${POSTGRES_USER:-malenia}:${POSTGRES_PASSWORD:-malenia_password}@postgres:5432/${POSTGRES_DB:-malenia_db}
PROXY: ${PROXY:-}
ADMIN_GROUP_ID: ${ADMIN_GROUP_ID}
REMNAWAVE_URL: ${REMNAWAVE_URL}
SUBSCRIPTION_URL: ${SUBSCRIPTION_URL}
REMNAWAVE_TOKEN: ${REMNAWAVE_TOKEN}
MIN_DEVICES: ${MIN_DEVICES:-3}
MAX_DEVICES: ${MAX_DEVICES:-12}
PER_DEVICE_COST: ${PER_DEVICE_COST:-50}
WHITELIST_COST: ${WHITELIST_COST:-100}
WHITELIST_DEVICE_THRESHOLD: ${WHITELIST_DEVICE_THRESHOLD:-6}
restart: unless-stopped
# Optional: uncomment to run with auto-reload for development
# command: python -m watchfiles main.py
stdin_open: true
tty: true
volumes:
postgres_data: