Fix utils.get_peer not handling Self in get_messages

This commit is contained in:
Lonami Exo 2020-10-23 19:02:43 +02:00
parent 44e2ef6c79
commit 1a2e09487c
3 changed files with 7 additions and 3 deletions

View File

@ -290,7 +290,7 @@ class _IDsIter(RequestIter):
else: else:
r = await self.client(functions.messages.GetMessagesRequest(ids)) r = await self.client(functions.messages.GetMessagesRequest(ids))
if self._entity: if self._entity:
from_id = utils.get_peer(self._entity) from_id = await self.client._get_peer(self._entity)
if isinstance(r, types.messages.MessagesNotModified): if isinstance(r, types.messages.MessagesNotModified):
self.buffer.extend(None for _ in ids) self.buffer.extend(None for _ in ids)
@ -804,7 +804,7 @@ class MessageMethods:
if isinstance(result, types.UpdateShortSentMessage): if isinstance(result, types.UpdateShortSentMessage):
message = types.Message( message = types.Message(
id=result.id, id=result.id,
peer_id=utils.get_peer(entity), peer_id=await self.client.get_peer(entity),
message=message, message=message,
date=result.date, date=result.date,
out=result.out, out=result.out,

View File

@ -463,6 +463,10 @@ class UserMethods:
.format(peer) .format(peer)
) )
async def _get_peer(self: 'TelegramClient', peer: 'hints.EntityLike'):
i, cls = utils.resolve_id(await self.get_peer_id(peer))
return cls(i)
async def get_peer_id( async def get_peer_id(
self: 'TelegramClient', self: 'TelegramClient',
peer: 'hints.EntityLike', peer: 'hints.EntityLike',

View File

@ -1,3 +1,3 @@
# Versions should comply with PEP440. # Versions should comply with PEP440.
# This line is parsed in setup.py: # This line is parsed in setup.py:
__version__ = '1.17.1' __version__ = '1.17.2'