Add channel state only if channel exist in entities (Correcting the situation when the channel was not written to entities, because it came in the form of min, and state was written and the next time it was turned on with the catch_up parameter, the script did not run)

This commit is contained in:
Kacnep89 2023-03-28 09:45:58 +05:00
parent a7e8160d72
commit b263536ab8

View File

@ -664,8 +664,10 @@ class TelegramBaseClient(abc.ABC):
ss, cs = self._message_box.session_state()
self.session.set_update_state(0, types.updates.State(**ss, unread_count=0))
now = datetime.datetime.now() # any datetime works; channels don't need it
entities_ids = [e.id for e in entities]
for channel_id, pts in cs.items():
self.session.set_update_state(channel_id, types.updates.State(pts, 0, now, 0, unread_count=0))
if channel_id in entities_ids:
self.session.set_update_state(channel_id, types.updates.State(pts, 0, now, 0, unread_count=0))
async def _disconnect_coro(self: 'TelegramClient'):
if self.session is None: