UserBot Integration Complete: Fixed container startup, integrated UserBot menu to main bot

MAJOR FIXES:
 Fixed UserBot container startup by making TELEGRAM_BOT_TOKEN optional
 Broke circular import chain between app modules
 Made Config.validate() conditional for UserBot-only mode
 Removed unused celery import from userbot_service.py

INTEGRATION:
 UserBot menu now accessible from main bot /start command
 Added 🤖 UserBot button to main keyboard
 Integrated userbot_manager.py handlers:
   - userbot_menu: Main UserBot interface
   - userbot_settings: Configuration
   - userbot_collect_groups: Gather all user groups
   - userbot_collect_members: Parse group members
 UserBot handlers properly registered in ConversationHandler

CONTAINERS:
 tg_autoposter_bot: Running and handling /start commands
 tg_autoposter_userbot: Running as standalone microservice
 All dependent services (Redis, PostgreSQL, Celery workers) operational

STATUS: Bot is fully operational and ready for testing
This commit is contained in:
2025-12-21 12:09:11 +09:00
parent b8136138dc
commit 48f8c6f0eb
48 changed files with 6593 additions and 113 deletions

View File

@@ -250,7 +250,7 @@ services:
networks:
- autoposter_network
command: celery -A app.celery_config beat --loglevel=info --scheduler django_celery_beat.schedulers:DatabaseScheduler
command: celery -A app.celery_config beat --loglevel=info
restart: unless-stopped
# ════════════════════════════════════════════════════════════════
@@ -277,6 +277,50 @@ services:
command: celery --broker=redis://${REDIS_PASSWORD:+:${REDIS_PASSWORD}@}${REDIS_HOST:-redis}:${REDIS_PORT:-6379}/${REDIS_DB:-0} flower --port=5555
restart: unless-stopped
# ════════════════════════════════════════════════════════════════
# Telethon UserBot Microservice
# ════════════════════════════════════════════════════════════════
userbot:
build:
context: .
dockerfile: Dockerfile.userbot
container_name: tg_autoposter_userbot
environment:
# Telethon Client
USE_TELETHON: ${USE_TELETHON:-true}
TELETHON_API_ID: ${TELETHON_API_ID}
TELETHON_API_HASH: ${TELETHON_API_HASH}
TELETHON_PHONE: ${TELETHON_PHONE}
TELETHON_FLOOD_WAIT_MAX: ${TELETHON_FLOOD_WAIT_MAX:-60}
# Database (PostgreSQL)
DATABASE_URL: postgresql+asyncpg://${DB_USER:-autoposter}:${DB_PASSWORD:-autoposter_password}@postgres:5432/${DB_NAME:-autoposter_db}
# Redis & Celery
REDIS_HOST: ${REDIS_HOST:-redis}
REDIS_PORT: ${REDIS_PORT:-6379}
REDIS_DB: ${REDIS_DB:-0}
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
# Logging
LOG_LEVEL: ${LOG_LEVEL:-INFO}
volumes:
- ./app:/app/app
- ./logs:/app/logs
- ./sessions:/app/sessions
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- autoposter_network
restart: unless-stopped
volumes:
postgres_data:
driver: local