Copy entire Telegram channels (history, albums, media and all) across as many userbot accounts as you own.
Hebrew management bot. Crash-proof checkpoints. Real parallelism.
|
Getting started |
Copying |
Operations |
|
One runner per userbot account, all copying at once: across jobs, and inside a single job once two accounts can reach its channels. |
A job's ID range is split into ~200 chunks, each with its own checkpoint. Kill the process mid-copy; it resumes exactly where it stopped. |
Every processed message ID is recorded. Stale checkpoints, crashes and reclaimed chunks can't produce a duplicate. |
|
Telegram limits are per account, so the daily cap is too. A spent account steps aside; the rest keep going at full speed. |
One account may be in a channel while another isn't. Each probes for itself, and the UI reports exactly who can reach what. |
Media groups stay grouped. "No forwarding" channels fall back to download-and-reupload automatically. |
|
Copy the history, then keep listening for new messages in real time, with the same filters and dedup. |
Scan a channel for duplicated media, get a Telegraph report with links, and bulk-delete the waste. |
A single message, edited in place, never a wall of new ones. Jobs, sources, filters and settings, all inline. |
Two processes that share nothing but a SQLite file:
| Component | Library | Role |
|---|---|---|
| ๐ค Management bot | Telethon (MTProto bot mode) |
Hebrew UI, job creation, configuration |
| ๐ท Userbot worker | Telethon (MTProto user mode) |
Executes copy jobs, updates progress |
Important
SQLite is the only IPC channel. Neither process ever calls the other directly.
graph TD
subgraph BOT["๐ค Management Bot"]
UI["๐ฎ๐ฑ Hebrew control panel"]
end
DB[("๐๏ธ SQLite ยท WAL")]
subgraph WORKER["๐ท Userbot Worker"]
M["๐ UserbotManager"]
M --> R1["Runner ยท account 1"]
M --> R2["Runner ยท account 2"]
M --> R3["Runner ยท account N"]
end
UI <-->|"jobs, sources, settings"| DB
DB <-->|"claim ยท checkpoint ยท progress"| M
R1 --> TG(["๐ก Telegram"])
R2 --> TG
R3 --> TG
style DB fill:#0D1117,stroke:#06B6D4,color:#fff
style TG fill:#0088CC,stroke:#0088CC,color:#fff
The job lifecycle
stateDiagram-v2
[*] --> draft
draft --> pending: submit
pending --> running: claimed by an account
running --> completed: source exhausted
running --> waiting_retry: FloodWait / error
waiting_retry --> pending: next_retry_at passes
running --> paused: user, or max retries
paused --> pending: resume
running --> failed: retries exhausted
running --> cancelled: user
completed --> [*]
failed --> [*]
cancelled --> [*]
# 1 ยท install
pip install -r requirements.txt
# 2 ยท configure
cp example.env .env # then fill it in (see below)
# 3 ยท authenticate the userbot (one time, asks for phone + code)
python main.py setup
# 4 ยท go
python main.py allโ๏ธ ย What goes in .env
| Variable | Where from |
|---|---|
BOT_TOKEN |
@BotFather |
TELETHON_API_ID |
my.telegram.org |
TELETHON_API_HASH |
my.telegram.org |
TELETHON_SESSION |
Path for the session file, e.g. sessions/userbot |
ADMIN_IDS |
Comma-separated Telegram user IDs allowed to use the bot |
The .env account is registered automatically as the default userbot on first
run. Every account after that is added from the bot UI, with no .env edits needed.
๐ ย Run modes
| Command | What it starts |
|---|---|
python main.py all |
Bot and worker in one process (simplest) |
python main.py bot |
Management bot only |
python main.py worker |
Userbot worker only |
python main.py setup |
One-time session authentication |
bot and worker can run as two separate processes instead; they coordinate
through the database either way.
๐ ย Requirements
- ๐ Python 3.11+
- ๐ค One or more Telegram accounts (for the userbots)
- ๐ค A Telegram bot token
- ๐ API credentials from my.telegram.org
graph LR
A["๐ /start"] --> B["โ Add source<br>and destination"]
B --> C["๐ค Add accounts<br><i>optional</i>"]
C --> D["๐ Create job"]
D --> E["๐ค Submit"]
E --> F["๐ Watch it run"]
style A fill:#06B6D4,stroke:#06B6D4,color:#fff
style F fill:#D98324,stroke:#D98324,color:#fff
- ๐ Send
/startto the management bot, and a Hebrew control panel appears - โ Add source and destination channels via the UI
- ๐ค (optional) Add more userbot accounts: โ๏ธ ืืืืจืืช โ ๐ค ืืฉืืื ืืช ืืืืจืืื
- ๐ Create a job (pick a copy mode and its parameters)
- ๐ค Submit, and the worker picks it up automatically
- ๐ Watch progress in the job detail screen (press Refresh)
| Mode | Description | |
|---|---|---|
| โพ๏ธ | All messages | Every accessible message in the source |
| ๐ | Date range | Between two dates (DD/MM/YYYY HH:MM, Israel local time) |
| ๐ข | ID range | Between two numeric message IDs |
| ๐ฏ | Single message | One specific message, by ID |
| ๐ | Continuous | Copy the history, then keep listening for new messages |
Every active account gets its own runner: its own Telethon client, its own copy engine, its own claim loop. They all work at the same time.
graph TD
Q["๐ฅ Queue"] -->|claim_next_job| L["๐ค Leader"]
L --> S{"2+ accounts<br>reach both channels?"}
S -->|"no"| ORD["โก๏ธ One ordered pass<br><i>source order preserved</i>"]
S -->|"yes"| C["๐งฉ Split into ~200 chunks"]
C --> W1["๐ค Leader<br>works chunks"]
C --> W2["๐ค Free account<br>joins"]
C --> W3["๐ค Free account<br>joins"]
W1 --> F["๐ Leader waits for<br>the stragglers, then<br>closes the job"]
W2 --> F
W3 --> F
style S fill:#0D1117,stroke:#D98324,color:#fff
style ORD fill:#06B6D4,stroke:#06B6D4,color:#fff
style C fill:#D98324,stroke:#D98324,color:#fff
style F fill:#0D1117,stroke:#06B6D4,color:#fff
- Across jobs. Two queued jobs and two accounts mean each takes a whole job of its own. Always preferred: it is the fastest option and it preserves message order everywhere.
- Within one job. When nothing new is left to claim, free accounts join a job already in progress. The account that claimed it (its leader) checks how many active accounts can reach both channels:
| Accounts with access | What happens |
|---|---|
| 1 | A single ascending pass, exactly how a single-account install behaves |
| 2+ | The source ID range is split into ~200 chunks; every free account claims chunks of its own |
Chunks are claimed atomically, so no two accounts ever touch the same message. Throughput scales with the number of accounts, and so does the daily quota, since Telegram enforces its limits per account.
Warning
Order is the trade-off. Within a chunk the order is the source's, but chunks are copied concurrently and therefore interleave in the destination. This is inherent to splitting one job across accounts, not an implementation detail. If strict source order matters, run the job while only one account can reach the channels.
Note
Almost everything Telegram enforces is per account, not per job. The design follows that boundary rather than fighting it.
- Access is per account. One account may be a member of a channel while another is not. Each probes every channel for itself, and the channel detail screen reports exactly who can reach it.
- The daily cap is per account. A spent account simply stops claiming while the others carry on. Only when every account is capped does the queue park until midnight (Israel time), and the admin is told.
- Adding an account clears every job's exclusion list, since a new account may have access where the others didn't, so failed jobs get another chance.
|
โ Supported
|
โ Not supported
|
Each job picks which of text ยท image ยท video ยท file to copy. Protected
("no forwarding") sources are detected automatically and fall back to
download-and-reupload.
Configure a list of blocked words in the bot UI. Any message containing one, in text or caption, is skipped entirely. No editing, no partial removal: the whole message is skipped, and the count is tracked per job.
Built to survive process crashes:
| Guarantee | |
|---|---|
| ๐ | Worker crash mid-job. On next startup the worker spots the running job and re-queues it as pending. Every account assignment and held chunk from the previous run is released. |
| ๐ | Resume from checkpoint. An unsharded job resumes from jobs.last_processed_id. A sharded job keeps a checkpoint per chunk, so only the unfinished part of an interrupted chunk is redone. Finished chunks are never revisited. |
| ๐ซ | Abandoned chunks. A chunk whose owner has been silent for 30 minutes goes back to the queue. The window is deliberately generous: reclaiming too early would let two accounts copy the same messages. |
| ๐ | Duplicate prevention. copied_messages records every processed source message ID. Nothing there is ever re-sent, even if a checkpoint is stale. |
| ๐ | FloodWait. The job moves to waiting_retry with a next_retry_at, which the poll loop honours across restarts. A flood wait on a helper account never stalls the job; the others keep going. |
๐ ย Tree
app/
โโโ ๐ config.py # โ๏ธ environment config
โโโ ๐ db.py # ๐๏ธ SQLite connection, schema, migrations
โโโ ๐ models.py # ๐ฆ typed dataclasses
โโโ ๐ network_errors.py # ๐ network-failure classification
โ
โโโ ๐ repositories/ # ๐๏ธ Database access (one file per entity)
โ โโโ ๐ job_repo.py # job lifecycle, additive progress, atomic claiming
โ โโโ ๐ job_chunk_repo.py # ๐งฉ chunk planning/claiming, parallel copying
โ โโโ ๐ userbot_repo.py # userbot accounts, sessions, default account
โ โโโ ๐ channel_access_repo.py # per-account channel access results
โ โโโ ๐ dedup_repo.py # global transferred-content registry
โ โโโ ๐ scan_repo.py # duplicate scans and delete jobs
โ โโโ ๐ source_repo.py # sources and destinations
โ โโโ ๐ filter_repo.py # blocked words
โ โโโ ๐ admin_repo.py
โ โโโ ๐ state_repo.py # worker state, heartbeat, app_settings
โ
โโโ ๐ services/ # ๐ง Business logic
โ โโโ ๐ job_service.py
โ โโโ ๐ userbot_auth_service.py # interactive sign-in (phone โ code โ 2FA)
โ โโโ ๐ telegraph_service.py # Telegraph reports for failed/skipped messages
โ โโโ ๐ validation_service.py
โ
โโโ ๐ ui/ # ๐จ Interface building
โ โโโ ๐ texts.py # ๐ฎ๐ฑ all Hebrew strings
โ โโโ ๐ keyboards.py
โ โโโ ๐ renderer.py
โ
โโโ ๐ bot/ # ๐ค Management Bot (Telethon MTProto)
โ โโโ ๐ bot_main.py
โ โโโ ๐ state.py
โ โโโ ๐ handlers/
โ
โโโ ๐ worker/ # ๐ท Userbot Worker
โโโ ๐ worker_main.py # ๐ startup recovery, notifications, primary duties
โโโ ๐ userbot_manager.py # ๐ค one runner per account, claiming, parallelism
โโโ ๐ copy_engine.py # ๐ง Telethon copy logic + shard planning
โโโ ๐ scan_engine.py # ๐ duplicate scanning and bulk delete
โโโ ๐ rate_limiter.py # โณ delays and batch pauses
โโโ ๐ telegram_utils.py # ๐ entity resolution
๐ main.py # ๐ entry point (all | bot | worker | setup)
Tip
Every one of these is adjustable from the Settings screen in the management bot.
| Setting | Default | |
|---|---|---|
| โฑ๏ธ | Delay between messages | 2.0 โ 5.0s random (doubled after an album) |
| ๐งบ | Batch pause | 60 โ 120s after every 50 โ 100 messages |
| ๐ | FloodWait buffer | 5 โ 10s extra, random |
| ๐ | Max retries | 5 before a job fails or pauses |
| ๐ | Daily limit | 20,000 messages per account |
| โก | Concurrency | One runner per active account, all working at once |