Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
2.3 KiB
2.3 KiB
Tele2Bale Project Context
This project is a Python-based automation tool designed to transfer files and media from a Telegram bot to Bale's "Saved Messages" using a Userbot. It uses a multi-process architecture with a file-based queue system to ensure stability and reliable delivery of large files (bypassing the 50MB bot limit).
Architecture Overview
The application is split into two main components coordinated by a central runner:
- Orchestrator (
main.py): Spawns and manages two separate processes: the Telegram bot and the Bale worker. - Telegram Bot (
telebot.py):- Built using
Pyrogram. - Handles user interactions, receives media, and extracts URLs.
- Manages the task queue by writing to
queue/tasks.jsonl. - Provides a "Safe Mode" for ZIP encryption.
- Monitors
queue/status.jsonlfor real-time feedback.
- Built using
- Bale Worker (
bale.py):- Built using
aiobale. - Operates as a Userbot (logs in with a phone number) to allow uploading files larger than 50MB.
- Consumes tasks from the queue sequentially.
- Downloads files from direct URLs if necessary.
- Performs ZIP encryption when Safe Mode is enabled.
- Uploads files to the user's Saved Messages (
BALE_TARGET_ID).
- Built using
Key Files and Directories
main.py: Entry point that starts both the bot and the worker.telebot.py: Telegram bot logic.bale.py: Bale userbot worker logic.queue/: JSONL files for task management and status reporting.downloads/: Temporary storage for files.
Development & Configuration
Environment Variables (.env)
API_ID,API_HASH,BOT_TOKEN: Telegram API credentials.BALE_PHONE: Phone number for Bale authentication (+98...).BALE_TARGET_ID: UID of the target chat in Bale (e.g., Saved Messages ID).
Building and Running
- Install dependencies:
pip install -r requirements.txt - Initial Setup: Run
python3 bale.pymanually once to log in and create thebale_userbot.sessionfile. You will need to enter the verification code from Bale. - Run the application:
python3 main.py
Conventions
- Userbot for Large Files: Bale bots are limited to 50MB. This project uses a Userbot to bypass this restriction.
- Process Isolation: The bot and worker are independent and communicate via files.