mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-03-12 15:38:03 +03:00
Fix _get_peer was relying on old utils.resolve_id
This commit is contained in:
parent
9479e215fb
commit
d60ebbe6ea
|
@ -293,7 +293,7 @@ class _IDsIter(requestiter.RequestIter):
|
||||||
else:
|
else:
|
||||||
r = await self.client(_tl.fn.messages.GetMessages(ids))
|
r = await self.client(_tl.fn.messages.GetMessages(ids))
|
||||||
if self._entity:
|
if self._entity:
|
||||||
from_id = await self.client._get_peer(self._entity)
|
from_id = await _get_peer(self.client, self._entity)
|
||||||
|
|
||||||
if isinstance(r, _tl.messages.MessagesNotModified):
|
if isinstance(r, _tl.messages.MessagesNotModified):
|
||||||
self.buffer.extend(None for _ in ids)
|
self.buffer.extend(None for _ in ids)
|
||||||
|
@ -318,6 +318,14 @@ class _IDsIter(requestiter.RequestIter):
|
||||||
self.buffer.append(_custom.Message._new(self.client, message, entities, self._entity))
|
self.buffer.append(_custom.Message._new(self.client, message, entities, self._entity))
|
||||||
|
|
||||||
|
|
||||||
|
async def _get_peer(self: 'TelegramClient', input_peer: 'hints.EntityLike'):
|
||||||
|
try:
|
||||||
|
return utils.get_peer(input_peer)
|
||||||
|
except TypeError:
|
||||||
|
# Can only be self by now
|
||||||
|
return _tl.PeerUser(await self.get_peer_id(input_peer))
|
||||||
|
|
||||||
|
|
||||||
def get_messages(
|
def get_messages(
|
||||||
self: 'TelegramClient',
|
self: 'TelegramClient',
|
||||||
entity: 'hints.EntityLike',
|
entity: 'hints.EntityLike',
|
||||||
|
@ -480,7 +488,7 @@ async def send_message(
|
||||||
if isinstance(result, _tl.UpdateShortSentMessage):
|
if isinstance(result, _tl.UpdateShortSentMessage):
|
||||||
return _custom.Message._new(self, _tl.Message(
|
return _custom.Message._new(self, _tl.Message(
|
||||||
id=result.id,
|
id=result.id,
|
||||||
peer_id=await self._get_peer(entity),
|
peer_id=await _get_peer(self, entity),
|
||||||
message=message,
|
message=message,
|
||||||
date=result.date,
|
date=result.date,
|
||||||
out=result.out,
|
out=result.out,
|
||||||
|
|
|
@ -3573,9 +3573,6 @@ class TelegramClient:
|
||||||
ttl=None):
|
ttl=None):
|
||||||
return await uploads._file_to_media(**locals())
|
return await uploads._file_to_media(**locals())
|
||||||
|
|
||||||
async def _get_peer(self: 'TelegramClient', peer: 'hints.EntityLike'):
|
|
||||||
return await users._get_peer(**locals())
|
|
||||||
|
|
||||||
def _get_response_message(self: 'TelegramClient', request, result, input_chat):
|
def _get_response_message(self: 'TelegramClient', request, result, input_chat):
|
||||||
return messageparse._get_response_message(**locals())
|
return messageparse._get_response_message(**locals())
|
||||||
|
|
||||||
|
|
|
@ -323,10 +323,6 @@ async def get_input_entity(
|
||||||
.format(peer, type(peer).__name__)
|
.format(peer, type(peer).__name__)
|
||||||
)
|
)
|
||||||
|
|
||||||
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') -> int:
|
peer: 'hints.EntityLike') -> int:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user