mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-23 01:46:35 +03:00
Fix get_input_entity from peer ID not actually working
This commit is contained in:
parent
9d394ab18b
commit
804a29d0bc
|
@ -877,16 +877,20 @@ class TelegramClient(TelegramBareClient):
|
|||
# crc32(b'InputPeer') and crc32(b'Peer')
|
||||
type(entity).SUBCLASS_OF_ID in (0xc91c90b6, 0x2d45687)):
|
||||
ie = self.get_input_entity(entity)
|
||||
result = None
|
||||
if isinstance(ie, InputPeerUser):
|
||||
self.session.process_entities(GetUsersRequest([ie]))
|
||||
result = self(GetUsersRequest([ie]))
|
||||
elif isinstance(ie, InputPeerChat):
|
||||
self.session.process_entities(GetChatsRequest([ie.chat_id]))
|
||||
result = self(GetChatsRequest([ie.chat_id]))
|
||||
elif isinstance(ie, InputPeerChannel):
|
||||
self.session.process_entities(GetChannelsRequest([ie]))
|
||||
result = self(GetChannelsRequest([ie]))
|
||||
|
||||
# The result of Get*Request has been processed and the entity
|
||||
# cached if it was found.
|
||||
return self.session.entities[ie]
|
||||
if result:
|
||||
self.session.process_entities(result)
|
||||
try:
|
||||
return self.session.entities[ie]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
if isinstance(entity, str):
|
||||
return self._get_entity_from_string(entity)
|
||||
|
|
Loading…
Reference in New Issue
Block a user