From 4321b97e9887f24b68b5807e371251e519ee51ca Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 18 Sep 2021 16:36:11 +0200 Subject: [PATCH] No longer run send_code_request from sign_in --- readthedocs/misc/v2-migration-guide.rst | 7 +++++++ telethon/_client/auth.py | 9 ++------- telethon/_client/telegramclient.py | 2 -- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/readthedocs/misc/v2-migration-guide.rst b/readthedocs/misc/v2-migration-guide.rst index 995a412e..b1f3a483 100644 --- a/readthedocs/misc/v2-migration-guide.rst +++ b/readthedocs/misc/v2-migration-guide.rst @@ -428,6 +428,13 @@ However, most likely, you were already doing the right thing (or else you would' "why is this not being edited", which you would most likely consider a bug rather than a feature). +Signing in no longer sends the code +----------------------------------- + +``client.sign_in()`` used to run ``client.send_code_request()`` if you only provided the phone and +not the code. It no longer does this. If you need that convenience, use ``client.start()`` instead. + + The client.disconnected property has been removed ------------------------------------------------- diff --git a/telethon/_client/auth.py b/telethon/_client/auth.py index 27ef4767..05dd05c3 100644 --- a/telethon/_client/auth.py +++ b/telethon/_client/auth.py @@ -225,9 +225,7 @@ async def sign_in( if me: return me - if phone and not code and not password: - return await self.send_code_request(phone) - elif code: + if phone and code: phone, phone_code_hash = \ _parse_phone_and_hash(self, phone, phone_code_hash) @@ -247,10 +245,7 @@ async def sign_in( api_id=self.api_id, api_hash=self.api_hash ) else: - raise ValueError( - 'You must provide a phone and a code the first time, ' - 'and a password only if an RPCError was raised before.' - ) + raise ValueError('You must provide either phone and code, password, or bot_token.') result = await self(request) if isinstance(result, _tl.auth.AuthorizationSignUpRequired): diff --git a/telethon/_client/telegramclient.py b/telethon/_client/telegramclient.py index f3671e0b..5683e81f 100644 --- a/telethon/_client/telegramclient.py +++ b/telethon/_client/telegramclient.py @@ -381,8 +381,6 @@ class TelegramClient: You should only use this if you are not authorized yet. - This method will send the code if it's not provided. - .. note:: In most cases, you should simply use `start()` and not this method.