This script was created for a special case where we needed to extract usernames from a specific Telegram group and split them among team members for private messaging.
✅ Fetches a list of joined groups
✅ Scrapes active members from a selected group
✅ Allows filtering out inactive users
✅ Saves extracted members in JSON format
✅ Splits user lists into multiple parts for easier distribution
✅ Option to save splits as separate files or combined
Ensure you have Python installed, then install the required packages:
pip install telethon
Edit the script and replace:
API_ID = 'Replace it with your api id'
API_HASH = 'Replace it with your api hash'
Get your API credentials from my.telegram.org.
python main.py -scrapeThis will list all the groups you’ve joined and allow you to select one for scraping.
python main.py -splitThis will divide the members into equal parts for distribution.
python main.py -split -to-separate-filesBy default, the script excludes users who were last seen over a month ago. To include them, use:
python main.py -scrape -add-old-users