Skip to content

roseshayan/TopicRelay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📡 TopicRelay

Forward all videos from a Telegram forum topic to another group — automatically.

Python Telethon License Author

فارسی | English


What is TopicRelay?

TopicRelay is a Python script that connects to Telegram using your user account and forwards all videos from a specific forum topic (thread) in one group to another group — one by one, in chronological order.

Built for situations where you have hundreds of videos archived in a topic and need to migrate them to a different group, channel, or community.


✨ Features

  • 🔍 Auto-discovery — Scans an entire forum topic and collects all videos
  • 📋 Chronological order — Forwards from oldest to newest
  • 💾 Progress saving — Saves state every 20 messages; resumes from where it stopped if interrupted
  • 🚦 Rate limit handling — Detects Telegram's FloodWait and pauses automatically
  • 🔁 Auto retry — Retries each message up to 3 times on failure
  • 🎬 All video types — Handles both native Telegram videos and video files sent as documents
  • 📝 Detailed logging — Logs everything to console and forwarder.log
  • 🔒 No bot token needed — Uses a standard Telegram user account

📋 Requirements

  • Python 3.8 or higher
  • A Telegram user account (phone number login — not a bot token)
  • The account must be a member of both the source and destination groups

⚡ Quick Start

Step 1 — Get API Credentials

  1. Go to my.telegram.org
  2. Log in with your phone number
  3. Click "API development tools"
  4. Create a new application (any name is fine)
  5. Copy your api_id and api_hash

Step 2 — Install

git clone https://github.com/roseshayan/TopicRelay.git
cd TopicRelay
pip install -r requirements.txt

Step 3 — Find Your Group and Topic IDs

Open find_info.py, fill in your credentials, set TARGET_GROUP_ID to your source group, then run:

python find_info.py

This will print all your supergroups with their IDs, and all topics inside the target group.

Tip — Manual method: In Telegram Desktop, open the topic → right-click any message → Copy Message Link. The link looks like: https://t.me/c/GROUPID/TOPICID/MSGID The middle number is your Topic ID.

Step 4 — Configure

Edit the config block at the top of forwarder.py:

API_ID       = 12345678            # From my.telegram.org
API_HASH     = 'your_hash_here'    # From my.telegram.org

SOURCE_GROUP = -1001234567890      # Source group (with Topics enabled)
TOPIC_ID     = 999                 # Topic ID inside the source group
DEST_GROUP   = -1009876543210      # Destination group

DELAY_SECONDS = 3                  # Seconds between each forward (minimum 2)

Step 5 — Run

python forwarder.py

Log in with your phone number when prompted (e.g. +989123456789), then press Enter to start.


📁 Project Structure

TopicRelay/
├── forwarder.py      # Main script — collects and forwards videos
├── find_info.py      # Helper — lists group IDs and topic IDs
├── requirements.txt  # Dependencies
├── README.md         # This file (English)
└── README.fa.md      # Persian documentation

⚠️ Important Notes

Note Details
User account only Telegram bots cannot read message history. This script requires a real user account.
Session file After first login, a .session file is saved locally. Guard it like a password.
Forwarding restriction If the source group has "Restrict Saving Content" enabled, forwarding will fail.
Rate limits ~800 videos at 3s delay ≈ 40 minutes. The script handles FloodWait automatically.
Progress file progress.json tracks forwarded messages. Delete it to restart from scratch.

🔐 Security

  • Never share your api_id, api_hash, or .session files
  • Add *.session, progress.json, and forwarder.log to .gitignore (already included)
  • Revoke your API credentials at my.telegram.org if compromised

📄 License

This project is licensed under the MIT License.


👤 Author

SudoShayanNA


Built with ❤️ using Telethon

About

Forward all videos from a Telegram forum topic to another group, automatically.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages