mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-09 08:00:53 +03:00
Cast to input peer early on get input entity and close cursor
This commit is contained in:
parent
843e777eba
commit
932ed9ea9d
|
@ -355,12 +355,13 @@ class Session:
|
||||||
|
|
||||||
Raises ValueError if it cannot be found.
|
Raises ValueError if it cannot be found.
|
||||||
"""
|
"""
|
||||||
c = self._conn.cursor()
|
|
||||||
if isinstance(key, TLObject):
|
if isinstance(key, TLObject):
|
||||||
|
key = utils.get_input_peer(key)
|
||||||
if type(key).SUBCLASS_OF_ID == 0xc91c90b6: # crc32(b'InputPeer')
|
if type(key).SUBCLASS_OF_ID == 0xc91c90b6: # crc32(b'InputPeer')
|
||||||
return key
|
return key
|
||||||
key = utils.get_peer_id(key, add_mark=True)
|
key = utils.get_peer_id(key, add_mark=True)
|
||||||
|
|
||||||
|
c = self._conn.cursor()
|
||||||
if isinstance(key, str):
|
if isinstance(key, str):
|
||||||
phone = utils.parse_phone(key)
|
phone = utils.parse_phone(key)
|
||||||
if phone:
|
if phone:
|
||||||
|
@ -375,6 +376,7 @@ class Session:
|
||||||
c.execute('select id, hash from entities where id=?', (key,))
|
c.execute('select id, hash from entities where id=?', (key,))
|
||||||
|
|
||||||
result = c.fetchone()
|
result = c.fetchone()
|
||||||
|
c.close()
|
||||||
if result:
|
if result:
|
||||||
i, h = result # unpack resulting tuple
|
i, h = result # unpack resulting tuple
|
||||||
i, k = utils.resolve_id(i) # removes the mark and returns kind
|
i, k = utils.resolve_id(i) # removes the mark and returns kind
|
||||||
|
|
Loading…
Reference in New Issue
Block a user