mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 03:13:45 +03:00
Fix-up isinstance/is_user_authorized from 06cdf1f
This commit is contained in:
parent
b7286be3b0
commit
509fba8bcc
|
@ -192,6 +192,7 @@ class TelegramBaseClient(abc.ABC):
|
|||
# TODO maybe we can have ._last_request instead if any req works?
|
||||
self._last_state = datetime.now()
|
||||
self._state_delay = timedelta(hours=1)
|
||||
self._state = None
|
||||
|
||||
# Some further state for subclasses
|
||||
self._event_builders = []
|
||||
|
|
|
@ -35,8 +35,9 @@ class UserMethods(TelegramBaseClient):
|
|||
raise
|
||||
except (errors.PhoneMigrateError, errors.NetworkMigrateError,
|
||||
errors.UserMigrateError) as e:
|
||||
should_raise = isinstance(errors.PhoneMigrateError,
|
||||
errors.NetworkMigrateError)
|
||||
should_raise = isinstance(e, (
|
||||
errors.PhoneMigrateError, errors.NetworkMigrateError
|
||||
))
|
||||
if should_raise and await self.is_user_authorized():
|
||||
raise
|
||||
await self._switch_dc(e.new_dc)
|
||||
|
@ -79,9 +80,14 @@ class UserMethods(TelegramBaseClient):
|
|||
"""
|
||||
Returns ``True`` if the user is authorized.
|
||||
"""
|
||||
if self._authorized is None:
|
||||
self._authorized = await self.get_me() is not None
|
||||
return self._authorized
|
||||
if self._self_input_peer is not None or self._state is not None:
|
||||
return True
|
||||
|
||||
try:
|
||||
self._state = await self(functions.updates.GetStateRequest())
|
||||
return True
|
||||
except errors.RPCError:
|
||||
return False
|
||||
|
||||
async def get_entity(self, entity):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user