mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 19:33:45 +03:00
Update in-memory updates.State
This commit is contained in:
parent
4ab5c7d92d
commit
a1477a84bf
|
@ -92,6 +92,9 @@ class DialogMethods(UserMethods):
|
|||
if peer_id not in seen:
|
||||
seen.add(peer_id)
|
||||
cd = custom.Dialog(self, d, entities, messages)
|
||||
if cd.dialog.pts:
|
||||
self._channel_pts[cd.id] = cd.dialog.pts
|
||||
|
||||
if not ignore_migrated or getattr(
|
||||
cd.entity, 'migrated_to', None) is None:
|
||||
await yield_(cd)
|
||||
|
|
|
@ -13,7 +13,7 @@ from ..extensions import markdown
|
|||
from ..network import MTProtoSender, ConnectionTcpFull
|
||||
from ..network.mtprotostate import MTProtoState
|
||||
from ..sessions import Session, SQLiteSession
|
||||
from ..tl import TLObject, functions
|
||||
from ..tl import TLObject, functions, types
|
||||
from ..tl.alltlobjects import LAYER
|
||||
|
||||
DEFAULT_DC_ID = 4
|
||||
|
@ -219,9 +219,10 @@ class TelegramBaseClient(abc.ABC):
|
|||
self._last_ping = datetime.now()
|
||||
self._ping_delay = timedelta(minutes=1)
|
||||
|
||||
self._state = None
|
||||
self._updates_handle = None
|
||||
self._last_request = time.time()
|
||||
self._channel_pts = {}
|
||||
self._state = types.updates.State(0, 0, datetime.now(), 0, -1)
|
||||
|
||||
# Some further state for subclasses
|
||||
self._event_builders = []
|
||||
|
|
|
@ -175,12 +175,24 @@ class UpdateMethods(UserMethods):
|
|||
itertools.chain(update.users, update.chats)}
|
||||
for u in update.updates:
|
||||
u._entities = entities
|
||||
self._loop.create_task(self._dispatch_update(u))
|
||||
return
|
||||
self._handle_update(u)
|
||||
if isinstance(update, types.UpdateShort):
|
||||
update = update.update
|
||||
update._entities = {}
|
||||
self._loop.create_task(self._dispatch_update(update))
|
||||
self._handle_update(update.update)
|
||||
else:
|
||||
update._entities = getattr(update, '_entities', {})
|
||||
self._loop.create_task(self._dispatch_update(update))
|
||||
|
||||
need_diff = False
|
||||
if hasattr(update, 'pts'):
|
||||
if self._state.pts and (update.pts - self._state.pts) > 1:
|
||||
need_diff = True
|
||||
self._state.pts = update.pts
|
||||
if hasattr(update, 'date'):
|
||||
self._state.date = update.date
|
||||
if hasattr(update, 'seq'):
|
||||
self._state.seq = update.seq
|
||||
|
||||
# TODO make use of need_diff
|
||||
|
||||
async def _update_loop(self):
|
||||
# Pings' ID don't really need to be secure, just "random"
|
||||
|
|
Loading…
Reference in New Issue
Block a user