Fix is_user_authorized always returning True

This commit is contained in:
Lonami Exo 2018-06-21 09:32:09 +02:00
parent 8d5c052fce
commit cfa5cd0db2
2 changed files with 5 additions and 2 deletions

View File

@ -222,7 +222,10 @@ class TelegramBaseClient(abc.ABC):
self._updates_handle = None
self._last_request = time.time()
self._channel_pts = {}
self._state = types.updates.State(0, 0, datetime.now(), 0, -1)
# Start with invalid state (-1) so we can have somewhere to store
# the state, but also be able to determine if we are authorized.
self._state = types.updates.State(-1, 0, datetime.now(), 0, -1)
# Some further state for subclasses
self._event_builders = []

View File

@ -90,7 +90,7 @@ class UserMethods(TelegramBaseClient):
"""
Returns ``True`` if the user is authorized.
"""
if self._self_input_peer is not None or self._state is not None:
if self._self_input_peer is not None or self._state.pts != -1:
return True
try: