mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 12:59:46 +00:00
Make use of the async_generator module
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from collections import UserList
|
||||
|
||||
from async_generator import async_generator, yield_
|
||||
|
||||
from .users import UserMethods
|
||||
from .. import utils
|
||||
from ..tl import types, functions
|
||||
@@ -9,6 +11,7 @@ class ChatMethods(UserMethods):
|
||||
|
||||
# region Public methods
|
||||
|
||||
@async_generator
|
||||
async def iter_participants(
|
||||
self, entity, limit=None, search='',
|
||||
filter=None, aggressive=False, _total=None):
|
||||
@@ -130,7 +133,7 @@ class ChatMethods(UserMethods):
|
||||
seen.add(participant.user_id)
|
||||
user = users[participant.user_id]
|
||||
user.participant = participant
|
||||
yield user
|
||||
await yield_(user)
|
||||
if len(seen) >= limit:
|
||||
return
|
||||
|
||||
@@ -159,7 +162,7 @@ class ChatMethods(UserMethods):
|
||||
else:
|
||||
user = users[participant.user_id]
|
||||
user.participant = participant
|
||||
yield user
|
||||
await yield_(user)
|
||||
else:
|
||||
if _total:
|
||||
_total[0] = 1
|
||||
@@ -167,7 +170,7 @@ class ChatMethods(UserMethods):
|
||||
user = await self.get_entity(entity)
|
||||
if filter_entity(user):
|
||||
user.participant = None
|
||||
yield user
|
||||
await yield_(user)
|
||||
|
||||
async def get_participants(self, *args, **kwargs):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user