mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-06 05:00:23 +03:00
Async iter through all dialogs in get_input_peer
(instead of first 100 only)
This commit is contained in:
parent
ddf36c9cb0
commit
c4e20ded15
|
@ -2440,17 +2440,17 @@ class TelegramClient(TelegramBareClient):
|
||||||
|
|
||||||
# Add the mark to the peers if the user passed a Peer (not an int),
|
# Add the mark to the peers if the user passed a Peer (not an int),
|
||||||
# or said ID is negative. If it's negative it's been marked already.
|
# or said ID is negative. If it's negative it's been marked already.
|
||||||
# Look in the dialogs with the hope to find it.
|
# Look in the dialogs to find it.
|
||||||
if not self._called_get_dialogs:
|
if not self._called_get_dialogs:
|
||||||
self._called_get_dialogs = True
|
self._called_get_dialogs = True
|
||||||
mark = not isinstance(peer, int) or peer < 0
|
mark = not isinstance(peer, int) or peer < 0
|
||||||
target_id = utils.get_peer_id(peer)
|
target_id = utils.get_peer_id(peer)
|
||||||
if mark:
|
if mark:
|
||||||
async for dialog in self.iter_dialogs(100):
|
async for dialog in self.iter_dialogs(limit=None):
|
||||||
if utils.get_peer_id(dialog.entity) == target_id:
|
if utils.get_peer_id(dialog.entity) == target_id:
|
||||||
return utils.get_input_peer(dialog.entity)
|
return utils.get_input_peer(dialog.entity)
|
||||||
else:
|
else:
|
||||||
async for dialog in self.iter_dialogs(100):
|
async for dialog in self.iter_dialogs(limit=None):
|
||||||
if dialog.entity.id == target_id:
|
if dialog.entity.id == target_id:
|
||||||
return utils.get_input_peer(dialog.entity)
|
return utils.get_input_peer(dialog.entity)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user