From 804a29d0bc2d6daa57ea5e398a102c671acd6c1d Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 6 Oct 2017 21:05:02 +0200 Subject: [PATCH] Fix get_input_entity from peer ID not actually working --- telethon/telegram_client.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 079c9a9d..11037257 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -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)