mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 21:10:29 +00:00
Unify client.iter_* methods
This commit is contained in:
@@ -318,7 +318,7 @@ class _IDsIter(requestiter.RequestIter):
|
||||
self.buffer.append(_custom.Message._new(self.client, message, entities, self._entity))
|
||||
|
||||
|
||||
def iter_messages(
|
||||
def get_messages(
|
||||
self: 'TelegramClient',
|
||||
entity: 'hints.EntityLike',
|
||||
limit: float = None,
|
||||
@@ -368,25 +368,6 @@ def iter_messages(
|
||||
scheduled=scheduled
|
||||
)
|
||||
|
||||
async def get_messages(self: 'TelegramClient', *args, **kwargs) -> 'hints.TotalList':
|
||||
if len(args) == 1 and 'limit' not in kwargs:
|
||||
if 'min_id' in kwargs and 'max_id' in kwargs:
|
||||
kwargs['limit'] = None
|
||||
else:
|
||||
kwargs['limit'] = 1
|
||||
|
||||
it = self.iter_messages(*args, **kwargs)
|
||||
|
||||
ids = kwargs.get('ids')
|
||||
if ids and not utils.is_list_like(ids):
|
||||
async for message in it:
|
||||
return message
|
||||
else:
|
||||
# Iterator exhausted = empty, to handle InputMessageReplyTo
|
||||
return None
|
||||
|
||||
return await it.collect()
|
||||
|
||||
|
||||
async def _get_comment_data(
|
||||
self: 'TelegramClient',
|
||||
|
Reference in New Issue
Block a user