No longer run send_code_request from sign_in

This commit is contained in:
Lonami Exo 2021-09-18 16:36:11 +02:00
parent 431a9309e3
commit 4321b97e98
3 changed files with 9 additions and 9 deletions

View File

@ -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). "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 The client.disconnected property has been removed
------------------------------------------------- -------------------------------------------------

View File

@ -225,9 +225,7 @@ async def sign_in(
if me: if me:
return me return me
if phone and not code and not password: if phone and code:
return await self.send_code_request(phone)
elif code:
phone, phone_code_hash = \ phone, phone_code_hash = \
_parse_phone_and_hash(self, 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 api_id=self.api_id, api_hash=self.api_hash
) )
else: else:
raise ValueError( raise ValueError('You must provide either phone and code, password, or bot_token.')
'You must provide a phone and a code the first time, '
'and a password only if an RPCError was raised before.'
)
result = await self(request) result = await self(request)
if isinstance(result, _tl.auth.AuthorizationSignUpRequired): if isinstance(result, _tl.auth.AuthorizationSignUpRequired):

View File

@ -381,8 +381,6 @@ class TelegramClient:
You should only use this if you are not authorized yet. You should only use this if you are not authorized yet.
This method will send the code if it's not provided.
.. note:: .. note::
In most cases, you should simply use `start()` and not this method. In most cases, you should simply use `start()` and not this method.