mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 19:03:46 +03:00
Fix entities weren't being passed to Draft
This commit is contained in:
parent
81e628b9f7
commit
84c4fcdec6
|
@ -96,7 +96,12 @@ class _DialogsIter(RequestIter):
|
||||||
class _DraftsIter(RequestIter):
|
class _DraftsIter(RequestIter):
|
||||||
async def _init(self, **kwargs):
|
async def _init(self, **kwargs):
|
||||||
r = await self.client(functions.messages.GetAllDraftsRequest())
|
r = await self.client(functions.messages.GetAllDraftsRequest())
|
||||||
self.buffer.extend(custom.Draft._from_update(self.client, u)
|
|
||||||
|
# TODO Maybe there should be a helper method for this?
|
||||||
|
entities = {utils.get_peer_id(x): x
|
||||||
|
for x in itertools.chain(r.users, r.chats)}
|
||||||
|
|
||||||
|
self.buffer.extend(custom.Draft._from_update(self.client, u, entities)
|
||||||
for u in r.updates)
|
for u in r.updates)
|
||||||
|
|
||||||
async def _load_next_chunk(self):
|
async def _load_next_chunk(self):
|
||||||
|
|
|
@ -45,10 +45,10 @@ class Draft:
|
||||||
draft=dialog.dialog.draft, entity=dialog.entity)
|
draft=dialog.dialog.draft, entity=dialog.entity)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _from_update(cls, client, update, entities=None):
|
def _from_update(cls, client, update, entities):
|
||||||
assert isinstance(update, UpdateDraftMessage)
|
assert isinstance(update, UpdateDraftMessage)
|
||||||
return cls(client=client, peer=update.peer, draft=update.draft,
|
return cls(client=client, peer=update.peer, draft=update.draft,
|
||||||
entity=(entities or {}).get(get_peer_id(update.peer)))
|
entity=entities.get(get_peer_id(update.peer)))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def entity(self):
|
def entity(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user