A powerful Python script that helps you migrate users between Telegram groups. Perfect for community managers and group administrators who need to move members between groups efficiently.
- Migrate users between any Telegram groups (public or private)
- NEW: Multi-account support for faster migrations of large groups
- Batch processing to handle rate limits intelligently
- Colorful interface with progress bars
- Dry-run mode to test before actual migration
- Detailed logging and error reporting
- Progress tracking
- Command-line interface for easy use
- Skip bots and deleted accounts automatically
-
Python 3.9+ installed on your system
- Download from Python.org
- Make sure to check "Add Python to PATH" during installation
-
Visual C++ Build Tools (Windows only)
- Required for TgCrypto installation
- Download from Microsoft's website
-
Telegram API Credentials
- You'll need an
API_IDandAPI_HASH - Get them from my.telegram.org
- Log in with your phone number
- Click on "API Development Tools"
- Fill in the form (any name will do)
- Save your
API_IDandAPI_HASH
- You'll need an
-
Clone this repository:
git clone https://github.com/yourusername/telegram_user_migrator.git cd telegram_user_migrator -
Install required packages:
pip install -r requirements.txt
python telegram_user_migrator.py -a API_ID -H API_HASH -s SOURCE_GROUP -t TARGET_GROUP [options]python telegram_user_migrator.py -m accounts.json -s SOURCE_GROUP -t TARGET_GROUP [options]-aor--api-id: Your Telegram API ID (single account mode)-Hor--api-hash: Your Telegram API Hash (single account mode)-mor--multi-account: JSON file with multiple account credentials (multi-account mode)-sor--source-group: Source group to copy members from-tor--target-group: Target group to add members to-dor--dry-run: Test the migration without actually moving users-bor--batch-size: Number of users to process per batch (default: 5)-wor--wait-time: Wait time between batches in seconds (default: 30)-lor--limit: Limit number of users to migrate (default: 0, no limit)--filter-bots: Filter out bots from migration (enabled by default)--session: Custom session name for single account mode
You can specify groups in several ways:
- Username:
@groupname - Private group ID:
-1001234567890or-100123456789 - Basic group ID:
-123456789
-
Migrate from public to private group (single account):
python telegram_user_migrator.py -a 12345 -H "your_api_hash" -s "@sourcegroup" -t "-100987654321"
-
Migrate using multiple accounts:
python telegram_user_migrator.py -m accounts.json -s "@sourcegroup" -t "-100987654321"
-
Test migration with dry-run:
python telegram_user_migrator.py -a 12345 -H "your_api_hash" -s "@sourcegroup" -t "-100987654321" -d
-
Custom batch size and wait time:
python telegram_user_migrator.py -a 12345 -H "your_api_hash" -s "@sourcegroup" -t "-100987654321" -b 10 -w 15
To use multiple accounts, create a JSON file (e.g., accounts.json) with your account credentials:
[
{
"api_id": "12345",
"api_hash": "your_first_api_hash",
"session_name": "account1"
},
{
"api_id": "67890",
"api_hash": "your_second_api_hash",
"session_name": "account2"
}
]- Each account should have
api_idandapi_hash session_nameis optional and will be auto-generated if not provided- Using multiple accounts can make migration significantly faster
- The tool will automatically distribute users among available accounts
- If one account gets rate-limited, the tool will use another account
See accounts.json.example for a sample configuration.
-
For Public Groups: Just use the username with @ (e.g., @groupname)
-
For Private Groups:
- Forward any message from the group to @username_to_id_bot
- Or use the group's invite link - the numbers after the '/' are part of the ID
-
"Peer ID Invalid" Error
- Double-check the group ID format
- Make sure you're a member of both groups
- Verify that the bot/user has admin rights in the target group
-
Rate Limiting
- The script automatically handles rate limits by waiting
- Using multi-account mode can help bypass rate limiting issues
- Don't worry if you see "Waiting X seconds" messages
-
Privacy Restrictions
- Some users can't be added due to their privacy settings
- This is normal and the script will skip these users
After each run, the script generates detailed reports in:
migration_reports/report_YYYYMMDD_HHMMSS.json(machine-readable)migration_reports/report_YYYYMMDD_HHMMSS.txt(human-readable)
For multi-account migrations, reports include additional statistics:
- Per-account success rates
- Overall performance metrics
- Account distribution data
- Always run with
-d(dry-run) first to test - Keep your API credentials private
- Don't share the session files
- Respect Telegram's terms of service
- Don't use for spam or harassment
If you encounter any issues:
- Check the error message in the console
- Look at the generated report file
- Verify your permissions in both groups
- Make sure your API credentials are correct
This project is licensed under the MIT License - see the LICENSE file for details.