From b8d7b1c8af15231a27f816a8118780cfb7fc7cf4 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 20 Sep 2017 12:47:19 +0200 Subject: [PATCH] Phone number shouldn't actually start with '+' --- telethon/telegram_client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 05b4af7e..1c4c152c 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -282,8 +282,12 @@ class TelegramClient(TelegramBareClient): def send_code_request(self, phone): """Sends a code request to the specified phone number""" - result = self( - SendCodeRequest(phone, self.api_id, self.api_hash)) + if isinstance(phone, int): + phone = str(phone) + elif phone.startswith('+'): + phone = phone.strip('+') + + result = self(SendCodeRequest(phone, self.api_id, self.api_hash)) self._phone = phone self._phone_code_hash = result.phone_code_hash return result