mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 13:29:47 +00:00
Fix async_generator's and missing awaits
This commit is contained in:
@@ -179,8 +179,9 @@ class ChatMethods(UserMethods):
|
||||
"""
|
||||
total = [0]
|
||||
kwargs['_total'] = total
|
||||
participants = UserList(x async for x in
|
||||
self.iter_participants(*args, **kwargs))
|
||||
participants = UserList()
|
||||
async for x in self.iter_participants(*args, **kwargs):
|
||||
participants.append(x)
|
||||
participants.total = total[0]
|
||||
return participants
|
||||
|
||||
|
@@ -9,6 +9,7 @@ from ..tl import types, functions, custom
|
||||
|
||||
|
||||
class DialogMethods(UserMethods):
|
||||
|
||||
# region Public methods
|
||||
|
||||
@async_generator
|
||||
@@ -103,10 +104,13 @@ class DialogMethods(UserMethods):
|
||||
"""
|
||||
total = [0]
|
||||
kwargs['_total'] = total
|
||||
dialogs = UserList(x async for x in self.iter_dialogs(*args, **kwargs))
|
||||
dialogs = UserList()
|
||||
async for x in self.iter_dialogs(*args, **kwargs):
|
||||
dialogs.append(x)
|
||||
dialogs.total = total[0]
|
||||
return dialogs
|
||||
|
||||
@async_generator
|
||||
async def iter_drafts(self): # TODO: Ability to provide a `filter`
|
||||
"""
|
||||
Iterator over all open draft messages.
|
||||
@@ -124,6 +128,9 @@ class DialogMethods(UserMethods):
|
||||
"""
|
||||
Same as :meth:`iter_drafts`, but returns a list instead.
|
||||
"""
|
||||
return list(x async for x in self.iter_drafts())
|
||||
result = []
|
||||
async for x in self.iter_drafts():
|
||||
result.append(x)
|
||||
return result
|
||||
|
||||
# endregion
|
||||
|
@@ -244,7 +244,9 @@ class MessageMethods(UploadMethods, MessageParseMethods):
|
||||
else:
|
||||
kwargs['limit'] = 1
|
||||
|
||||
msgs = UserList(x async for x in self.iter_messages(*args, **kwargs))
|
||||
msgs = UserList()
|
||||
async for x in self.iter_messages(*args, **kwargs):
|
||||
msgs.append(x)
|
||||
msgs.total = total[0]
|
||||
if 'ids' in kwargs and not utils.is_list_like(kwargs['ids']):
|
||||
return msgs[0]
|
||||
|
Reference in New Issue
Block a user