Merge branch 'master' into asyncio

This commit is contained in:
Lonami Exo 2018-03-24 18:45:11 +01:00
commit 2ee5201229
2 changed files with 19 additions and 5 deletions

View File

@ -20,10 +20,24 @@ async def _into_id_set(client, chats):
result = set()
for chat in chats:
chat = await client.get_input_entity(chat)
if isinstance(chat, types.InputPeerSelf):
chat = await 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 = await 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

View File

@ -59,7 +59,7 @@ class Dialog:
self.entity = entities[utils.get_peer_id(dialog.peer)]
self.input_entity = utils.get_input_peer(self.entity)
self.id = utils.get_peer_id(self.input_entity)
self.id = utils.get_peer_id(self.entity) # ^ May be InputPeerSelf()
self.name = utils.get_display_name(self.entity)
self.unread_count = dialog.unread_count