How anasty17/mirror-leech-telegram-bot works
Main components
• Telegram Bot Interface: This is the entry point where the bot receives commands via Telegram. It consists of the core modules in the “bot” folder (e.g., bot/__main__.py, bot/core/*) and Telegram helper functions.
• Core Logic & Configuration: The “bot/core” modules handle startup, configuration management, and task scheduling. Include “bot/core/config_manager.py”, “bot/core/startup.py”, etc.
• Download/Upload Adapters: There are dedicated adapters for each supported service:
• Torrent downloaders: Under bot/helper/mirror_leech_utils/download_utils (for Aria2, direct, qBittorrent, jDownloader, etc.)
• Google Drive integration: Under bot/helper/mirror_leech_utils/gdrive_utils (with clone, count, delete, upload, etc.)
• Rclone integration: Under bot/helper/mirror_leech_utils/rclone_utils (listing, serve, transfer)
• Sabnzbd and JDownloader support: Separate modules (see sabnzbd, sabnzbdapi, and myjd folders)
• Yt-dlp and other direct link generators: Found in bot/helper/mirror_leech_utils and related helper modules.
• Listeners & Event Handlers: The “bot/helper/listeners” directory is responsible for listening to events or status from different download/upload engines.
• Web UI Component: The “web” directory includes the web server (web/wserver.py) and templates (web/templates) to interact with and select files (for example, for torrent file selection).
• Database Integration: Although not directly visible in the directory structure, the README details a Mongo database being used to store bot settings, user settings, and task data.
• Docker & Deployment Configuration: Files like Dockerfile, docker-compose.yml, and scripts like start.sh define the containerization, while the .dockerignore and GitHub workflows ensure proper deployment.
• External Scripts and Tools: Extra scripts such as add_to_team_drive.py, generate_drive_token.py, and others provide supporting functions (e.g., for interacting with Google OAuth, service account generation).
Relationships and interactions
• Incoming Telegram commands are received by the Bot Interface and processed by the core modules.
• Core modules trigger corresponding “modules” (from bot/modules), depending on the task (mirror, leech, clone, etc.).
• These modules call the appropriate download adapter (from bot/helper/mirror_leech_utils/download_utils, listeners, etc.) depending on the chosen service.
• The download/upload adapters interact with external services: Google Drive (via gdrive_utils), rclone (via rclone_utils), torrent clients, and video downloaders (yt-dlp) to process files.
• Status and progress are tracked via listeners and stored/updated in the Mongo database.
• The Web UI (web/wserver.py) serves pages showing task status, file selection pages for torrents or NZB downloads.
• Docker and deployment components tie all these services into a unified containerized service.
Architectural patterns and principles
• Modular Design: The project is organized into distinct packages (core, helper, modules) for separation of concerns.
• Asynchronous Programming: The README mentions asynchronous coding in Python, so note that many of the modules interact concurrently.
• Service-Adapter Pattern: Each external service (torrent client, cloud storage, downloaders) has its adapter making extensions easier.
• Configuration-driven Behavior: The extensive config_sample.py and usage of a Mongo database show that much of the behavior is driven by configuration parameters.
• Containerization: Dockerfile and docker-compose.yml indicate a cloud-ready, containerized application.
• Use clear segmentation between the Bot Interface, Task Handlers, Download/Upload Adapters, External Tools & Services, and the Database.
• Explicitly mark the Docker/Deployment layer and include external dependencies (MongoDB, Google APIs, Docker containers, etc.)