Hello. This library is awesome! I use Telethon 0.18.3 and Python 3.6.
I read exceptions in rpc_error_list, and I figured out that there are UserBlockedError, UserIsBlockedError, PhoneNumberBannedError etc. Can I catch one of these (f. e. PhoneNumberBannedError when I try to send_code_request or UserBlockedError when I try sign_in) to determine that user is banned by Telegram? I didn't find enough info about it in docs :(
P. S. Sorry for my English
Just catch the telethon.errors.rpc_error_list.PhoneNumberBannedError exception during client.send_code_request()
this_client = TelegramClient(phone_number, api_id, api_hash)
this_client.connect()
if not this_client.is_user_authorized():
try:
this_client.send_code_request(phone_number)
except telethon.errors.rpc_error_list.PhoneNumberBannedError:
print("Phone number is banned.")
this_client.disconnect()
Ok, thank you! But why there is no PhoneNumberBannedError in https://core.telegram.org/method/auth.sendCode Possible errors?
I just realized that official docs are outdated, so I found more info here https://lonamiwebs.github.io/Telethon/methods
Thank you!
@kaxap as a side note, errors are re-exported on telethon.errors, so telethon.errors.PhoneNumberBannedError is perfectly valid too. Thanks for helping out nevertheless.
Most helpful comment
@kaxap as a side note, errors are re-exported on
telethon.errors, sotelethon.errors.PhoneNumberBannedErroris perfectly valid too. Thanks for helping out nevertheless.