Как с помощью telethon узнать забанен ли аккаунт?

появился вопрос как проверить забанен ли аккаунт c библиотекой telethon?


Ответы (1 шт):

Автор решения: pasporty

При помощи исключения

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()
→ Ссылка