Dispatch updates to event handlers

This commit is contained in:
Lonami Exo
2018-06-13 16:20:15 +02:00
parent a91109c9fa
commit 3ce8b17193
4 changed files with 22 additions and 19 deletions

View File

@@ -12,7 +12,6 @@ from ..network.mtprotostate import MTProtoState
from ..sessions import Session, SQLiteSession
from ..tl import TLObject, functions
from ..tl.all_tlobjects import LAYER
from ..update_state import UpdateState
DEFAULT_DC_ID = 4
DEFAULT_IPV4_IP = '149.154.167.51'
@@ -171,17 +170,14 @@ class TelegramBaseClient(abc.ABC):
self._connection = connection
self._sender = MTProtoSender(
state, connection,
first_query=self._init_with(functions.help.GetConfigRequest())
first_query=self._init_with(functions.help.GetConfigRequest()),
update_callback=self._handle_update
)
# Cache :tl:`ExportedAuthorization` as ``dc_id: MTProtoState``
# to easily import them when getting an exported sender.
self._exported_auths = {}
# This member will process updates if enabled.
# One may change self.updates.enabled at any later point.
self.updates = UpdateState()
# Save whether the user is authorized here (a.k.a. logged in)
self._authorized = None # None = We don't know yet
@@ -367,4 +363,8 @@ class TelegramBaseClient(abc.ABC):
'use client(...) instead')
return await self(*args, **kwargs)
@abc.abstractmethod
def _handle_update(self, update):
raise NotImplementedError
# endregion