mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 11:23:46 +03:00
Make EntityDatabase.get a no-op if key is an entity already
This commit is contained in:
parent
e5c4df98df
commit
d2e244817a
|
@ -117,8 +117,14 @@ class EntityDatabase:
|
|||
if isinstance(key, int):
|
||||
return self._entities[key] # normal IDs are assumed users
|
||||
|
||||
if isinstance(key, TLObject) and type(key).SUBCLASS_OF_ID == 0x2d45687:
|
||||
if isinstance(key, TLObject):
|
||||
sc = type(key).SUBCLASS_OF_ID
|
||||
if sc == 0x2d45687:
|
||||
# Subclass of "Peer"
|
||||
return self._entities[utils.get_peer_id(key, add_mark=True)]
|
||||
elif sc in {0x2da17977, 0xc5af5d94, 0x6d44b7db}:
|
||||
# Subclass of "User", "Chat" or "Channel"
|
||||
return key
|
||||
|
||||
raise KeyError(key)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user