mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 12:40:22 +03:00
Merge branch 'master' into asyncio
This commit is contained in:
commit
2ee5201229
|
@ -20,10 +20,24 @@ async def _into_id_set(client, chats):
|
||||||
|
|
||||||
result = set()
|
result = set()
|
||||||
for chat in chats:
|
for chat in chats:
|
||||||
chat = await client.get_input_entity(chat)
|
if isinstance(chat, int):
|
||||||
if isinstance(chat, types.InputPeerSelf):
|
if chat < 0:
|
||||||
chat = await client.get_me(input_peer=True)
|
result.add(chat) # Explicitly marked IDs are negative
|
||||||
result.add(utils.get_peer_id(chat))
|
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
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ class Dialog:
|
||||||
|
|
||||||
self.entity = entities[utils.get_peer_id(dialog.peer)]
|
self.entity = entities[utils.get_peer_id(dialog.peer)]
|
||||||
self.input_entity = utils.get_input_peer(self.entity)
|
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.name = utils.get_display_name(self.entity)
|
||||||
|
|
||||||
self.unread_count = dialog.unread_count
|
self.unread_count = dialog.unread_count
|
||||||
|
|
Loading…
Reference in New Issue
Block a user