Telegram bot: Free nickname parser (TXT → TXT) • Python, Tel
What was done: Telegram bot with a "Parsing" button. The user uploads a TXT (1 username per line), the bot checks the availability of the username via MTProto (Telethon) and returns a TXT only with available usernames.
Main functionality
• Upload TXT in the chat → process the list → output TXT with available ones.
• Format validation (^[a-z][a-z0-9_]{4,31}$, 5–32, first — letter).
• Availability check: get_entity() with handling UsernameNotOccupiedError/ValueError as free.
• Anti-flood: semaphore MAX_CONCURRENCY, pause RATE_LIMIT_SLEEP_SEC, retry after FloodWait.
• Deduplication, normalization (@, spaces, case), file size limitation.
• Encoding: UTF-8 (fallback cp1251), file is always non-empty (placeholder if free=0).
• Access only for ADMIN_IDS.
• Configs via config.py (without .env).
Stack
Python 3.11 • python-telegram-bot 21.x • Telethon 1.36 • asyncio • logging.
Performance
Practically 1k usernames — processing in a few minutes (≈15–25 usernames/s depending on the network; tuning via MAX_CONCURRENCY, RATE_LIMIT_SLEEP_SEC).
Result
MVP bot that reliably returns TXT with available usernames; easy to scale/enhance (status bar, chunking, CSV export, etc.).
Main functionality
• Upload TXT in the chat → process the list → output TXT with available ones.
• Format validation (^[a-z][a-z0-9_]{4,31}$, 5–32, first — letter).
• Availability check: get_entity() with handling UsernameNotOccupiedError/ValueError as free.
• Anti-flood: semaphore MAX_CONCURRENCY, pause RATE_LIMIT_SLEEP_SEC, retry after FloodWait.
• Deduplication, normalization (@, spaces, case), file size limitation.
• Encoding: UTF-8 (fallback cp1251), file is always non-empty (placeholder if free=0).
• Access only for ADMIN_IDS.
• Configs via config.py (without .env).
Stack
Python 3.11 • python-telegram-bot 21.x • Telethon 1.36 • asyncio • logging.
Performance
Practically 1k usernames — processing in a few minutes (≈15–25 usernames/s depending on the network; tuning via MAX_CONCURRENCY, RATE_LIMIT_SLEEP_SEC).
Result
MVP bot that reliably returns TXT with available usernames; easy to scale/enhance (status bar, chunking, CSV export, etc.).