mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-09 08:00:53 +03:00
Early return from Session.get_input_entity() if Input* given
This commit is contained in:
parent
86816a3bdf
commit
f1371c3999
|
@ -401,12 +401,16 @@ class Session:
|
||||||
|
|
||||||
Raises ValueError if it cannot be found.
|
Raises ValueError if it cannot be found.
|
||||||
"""
|
"""
|
||||||
if isinstance(key, TLObject):
|
try:
|
||||||
try:
|
if key.SUBCLASS_OF_ID in (0xc91c90b6, 0xe669bf46, 0x40f202fd):
|
||||||
# Try to early return if this key can be casted as input peer
|
# hex(crc32(b'InputPeer', b'InputUser' and b'InputChannel'))
|
||||||
return utils.get_input_peer(key)
|
# We already have an Input version, so nothing else required
|
||||||
except TypeError:
|
return key
|
||||||
# Otherwise, get the ID of the peer
|
# Try to early return if this key can be casted as input peer
|
||||||
|
return utils.get_input_peer(key)
|
||||||
|
except (AttributeError, TypeError):
|
||||||
|
# Not a TLObject or can't be cast into InputPeer
|
||||||
|
if isinstance(key, TLObject):
|
||||||
key = utils.get_peer_id(key)
|
key = utils.get_peer_id(key)
|
||||||
|
|
||||||
c = self._conn.cursor()
|
c = self._conn.cursor()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user