This repository contains a modular Python application that allows you to migrate users from one Telegram group to another. The application uses multiple Telethon clients in a round-robin fashion for optimal performance and reliability.
The application has been refactored into a modular structure with the following components:
- Bot Client: Handles user commands and interface (
/start,/help, inline buttons) - User Clients: Multiple user accounts for sending invitations (round-robin switching)
- Account Manager: Manages multiple user account connections and authentication
- User Filter: Filters users based on activity (only includes users active within the last week)
- Migration Engine: Handles the core migration logic with round-robin account switching
- Bot Handlers: Manages all bot commands and callback handlers
Telegram_Bot_Bulk_Inviter/
├── main.py # Main entry point
├── config.py # Configuration file (not included in git)
├── config_template.py # Configuration template
├── account_manager.py # Account management module
├── user_filter.py # User filtering module
├── migration_engine.py # Migration logic module
├── bot_handlers.py # Bot command handlers
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore file
└── README.md # This file
- Modular architecture for better maintainability and extensibility
- Multiple user accounts with round-robin switching for higher throughput
- Smart user filtering (only migrates users active within the last week)
- Inline buttons for selecting source and target groups
- Real-time progress updates with detailed statistics
- Automatic bot detection and skipping
- Flood control with configurable delays and retry logic
- Account limiting (200 invites per account per day by default)
- Graceful error handling for various Telegram API errors
- Python 3.7+
- Telethon library
- Multiple Telegram user accounts (phone numbers) with permission to add users
- A Telegram bot token (obtained from BotFather)
-
Clone this repository:
git clone <repository-url> cd Telegram_Bot_Bulk_Inviter
-
Install required dependencies:
pip install -r requirements.txt
-
Create configuration file:
cp config_template.py config.py
-
Edit the configuration file with your credentials:
# config.py api_id = 1234567 # Your API ID from my.telegram.org api_hash = 'YOUR_API_HASH' # Your API Hash from my.telegram.org bot_token = 'YOUR_BOT_TOKEN' # Your bot token from BotFather # Add your user accounts (first one is main account for scraping) account_configs = [ {"phone": "+1234567890", "session": "user_session1"}, # main account {"phone": "+1234567891", "session": "user_session2"}, # Add more accounts as needed ]
-
API ID & API Hash:
- Go to my.telegram.org/apps
- Login with your phone number
- Create a new application
- Copy the
api_idandapi_hash
-
Bot Token:
- Open Telegram and search for @BotFather
- Create a new bot with
/newbot - Copy the bot token
-
User Accounts:
- Add multiple phone numbers to the
account_configslist - The first account is used for scraping members (main account)
- Additional accounts are used for sending invites in round-robin fashion
- Add multiple phone numbers to the
MAX_INVITES_PER_ACCOUNT: Maximum invites per account per day (default: 200)BATCH_SIZE: Number of invites per account before switching (default: 3)
-
Start the application:
python main.py
-
First-time setup:
- The script will prompt for verification codes for each phone number
- Enter the codes sent to your Telegram accounts
- If you have 2FA enabled, enter your password when prompted
-
Using the bot:
- Open Telegram and start a chat with your bot
- Type
/startto begin - Follow the inline button prompts to:
- Select source group (to scrape members from)
- Select target group (to invite members to)
- Start the migration process
-
Monitor progress:
- The bot provides real-time updates including:
- Number of members processed
- Successful invites
- Error counts by type
- Elapsed time and ETA
- The bot provides real-time updates including:
Handles connection and authentication of multiple user accounts. Manages account usage tracking and blocking status.
Filters users based on their last seen status. Only includes users who were active within the last week to improve migration success rate.
Core migration logic with round-robin account switching. Handles invite sending, error handling, and retry logic.
Contains all Telegram bot command handlers and callback query handlers for the user interface.
-
Install Python and dependencies:
# Ubuntu/Debian sudo apt update sudo apt install python3 python3-pip git -y # CentOS/RHEL sudo yum install python3 python3-pip git -y
-
Clone and setup:
git clone <repository-url> cd Telegram_Bot_Bulk_Inviter pip3 install -r requirements.txt cp config_template.py config.py # Edit config.py with your credentials
-
Run in background (optional):
# Using screen screen -S telegram-bot python3 main.py # Press Ctrl+A then D to detach # Using tmux tmux new-session -d -s telegram-bot 'python3 main.py'
- The
config.pyfile is automatically excluded from git via.gitignore - Never commit your configuration file or session files to version control
- Session files are created automatically and contain authentication data
- Keep your API credentials and bot token secure
- PeerFloodError: Account temporarily banned from inviting. The script automatically marks these accounts as blocked.
- FloodWaitError: Rate limiting. The script waits the required time and retries.
- UserPrivacyRestrictedError: User has privacy settings preventing invites.
- Session errors: Delete session files and re-authenticate.
The bot tracks different types of errors:
- Deleted accounts: Users who have deleted their accounts
- Privacy restricted: Users with strict privacy settings
- Blocked: Users who have blocked the inviting account
- Bots: Bot accounts (automatically skipped)
- Flood errors: Rate limiting and flood control
- This tool is for educational and administrative purposes only
- Use only on groups you own or have permission to manage
- Respect Telegram's Terms of Service
- The author is not responsible for any account bans or misuse
This project is distributed under the MIT License.