Fix get_input_entity from peer ID not actually working

This commit is contained in:
Lonami Exo 2017-10-06 21:05:02 +02:00
parent 9d394ab18b
commit 804a29d0bc

View File

@ -877,16 +877,20 @@ class TelegramClient(TelegramBareClient):
# crc32(b'InputPeer') and crc32(b'Peer') # crc32(b'InputPeer') and crc32(b'Peer')
type(entity).SUBCLASS_OF_ID in (0xc91c90b6, 0x2d45687)): type(entity).SUBCLASS_OF_ID in (0xc91c90b6, 0x2d45687)):
ie = self.get_input_entity(entity) ie = self.get_input_entity(entity)
result = None
if isinstance(ie, InputPeerUser): if isinstance(ie, InputPeerUser):
self.session.process_entities(GetUsersRequest([ie])) result = self(GetUsersRequest([ie]))
elif isinstance(ie, InputPeerChat): elif isinstance(ie, InputPeerChat):
self.session.process_entities(GetChatsRequest([ie.chat_id])) result = self(GetChatsRequest([ie.chat_id]))
elif isinstance(ie, InputPeerChannel): 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 if result:
# cached if it was found. self.session.process_entities(result)
return self.session.entities[ie] try:
return self.session.entities[ie]
except KeyError:
pass
if isinstance(entity, str): if isinstance(entity, str):
return self._get_entity_from_string(entity) return self._get_entity_from_string(entity)