How nhnobnd1/mirror-leech-telegram-bot works
Main Components
• Telegram Bot Interface:
• This is the primary interaction layer where users send commands (like mirror, leech, clone, etc.) to the bot through Telegram.
• Command Modules (in bot/modules):
• These modules – such as mirror, leech, clone, eval, search, etc. – represent the business logic and command handling parts.
• Helper Libraries:
• Under bot/helper, there are multiple subcomponents:
ext_utils: Contains utilities for database handling, file system utilities, exception handling, and queuing (queued_starter).
mirror_utils: Manages download and upload logic, with submodules for different downloaders (aria2/ qbittorrent, yt_dlp, etc.) and status tracking (status_utils).
telegram_helper: Contains utilities to construct Telegram bot commands, messages, filters, and button layouts.
• Downloaders and Uploaders:
• There is a clear separation between modules that handle downloading tasks (torrent downloaders like aria2, qBittorrent, yt_dlp, and direct link downloaders) and modules that handle uploading tasks to either Google Drive, Telegram, or other endpoints.
• The “mirror_utils/upload_utils” for example includes gdriveTools and pyrogramEngine.
• Google Drive & Service Accounts:
• The “accounts” folder holds Service Account credentials—vital for Google Drive uploads, especially with the use of multiple accounts to bypass rate limits.
• Database Integration:
• MongoDB is used to store bot and user settings, thumbnails, unfinished tasks, RSS data, and more.
• Web Interface:
• The “web” directory (with files like wserver.py and nodes.py) indicates an additional web component, most likely to serve index links or provide status pages of ongoing tasks.
• Deployment and CI/CD:
• Files like Dockerfile, docker-compose.yml, Jenkindsfile, and deployment scripts (e.g., start.sh, aria.sh) indicate that the project has containerization and potential CI/CD automation.
Relationships and Interactions
From Telegram user → Telegram Bot Interface → Command Modules.
From Command Modules → (via helper libraries) → Appropriate Downloader Modules (e.g., mirror_utils/download_utils) to fetch content.
From Downloader Modules → Uploader Modules which then interact with Google Drive or Telegram (and others).
The Bot also interacts with a database (MongoDB) via the ext_utils/db_handler to store state and settings.
The web component should have a two-way interaction with data from the bot (for status pages) and may interact with the database.
Architectural Patterns & Design Principles
• Modular architecture: The bot’s logic is clearly separated into modules (commands, helpers, mirror utilities), making it easier to extend functionality.
• Asynchronous processing: Note that the README mentions switching from sync to async; include a note that download/upload tasks use asynchronous execution.
• Containerization: The deployment part should show a Docker container encapsulating the bot application with separate builds for web and bot functionalities if needed.
Technologies, Frameworks, and Tools
• Python: The core language in which the bot is implemented.
• Pyrogram: Used for interacting with Telegram.
• qBittorrent, Aria2c, yt-dlp: For handling torrent and direct downloads.
• MongoDB: For persistent storage.
• Docker & Docker-Compose: For containerized deployment.
• Service Accounts (Google Cloud): For handling Drive uploads.
• Additional utilities: 7-zip or similar (for file archive extraction), and possibly the use of external APIs (Torrent Search API).