diff --git a/telethon/events/__init__.py b/telethon/events/__init__.py index 8b80bfd8..ff8f8d48 100644 --- a/telethon/events/__init__.py +++ b/telethon/events/__init__.py @@ -20,10 +20,24 @@ def _into_id_set(client, chats): result = set() for chat in chats: - chat = client.get_input_entity(chat) - if isinstance(chat, types.InputPeerSelf): - chat = client.get_me(input_peer=True) - result.add(utils.get_peer_id(chat)) + if isinstance(chat, int): + if chat < 0: + result.add(chat) # Explicitly marked IDs are negative + else: + result.update({ # Support all valid types of peers + utils.get_peer_id(types.PeerUser(chat)), + utils.get_peer_id(types.PeerChat(chat)), + utils.get_peer_id(types.PeerChannel(chat)), + }) + elif isinstance(chat, TLObject) and chat.SUBCLASS_OF_ID == 0x2d45687: + # 0x2d45687 == crc32(b'Peer') + result.add(utils.get_peer_id(chat)) + else: + chat = client.get_input_entity(chat) + if isinstance(chat, types.InputPeerSelf): + chat = client.get_me(input_peer=True) + result.add(utils.get_peer_id(chat)) + return result