Retry send_code_request on AuthRestartError

This commit is contained in:
Lonami Exo 2018-06-13 10:55:37 +02:00
parent 8a787e90c2
commit a91109c9fa

View File

@ -311,8 +311,12 @@ class AuthMethods(MessageParseMethods, UserMethods):
phone_hash = self._phone_code_hash.get(phone)
if not phone_hash:
result = await self(functions.auth.SendCodeRequest(
phone, self.api_id, self.api_hash))
try:
result = await self(functions.auth.SendCodeRequest(
phone, self.api_id, self.api_hash))
except errors.AuthRestartError:
return self.send_code_request(phone, force_sms=force_sms)
self._tos = result.terms_of_service
self._phone_code_hash[phone] = phone_hash = result.phone_code_hash
else: