Return helpers.TotalList instances on client.get_ methods

This commit is contained in:
Lonami Exo
2018-08-02 23:00:10 +02:00
parent a1837431b6
commit 7cce7aa3e4
7 changed files with 46 additions and 20 deletions

View File

@@ -1,9 +1,7 @@
from collections import UserList
from async_generator import async_generator, yield_
from .users import UserMethods
from .. import utils
from .. import utils, helpers
from ..tl import types, functions
@@ -169,12 +167,12 @@ class ChatMethods(UserMethods):
async def get_participants(self, *args, **kwargs):
"""
Same as :meth:`iter_participants`, but returns a list instead
with an additional ``.total`` attribute on the list.
Same as `iter_participants`, but returns a
`TotalList <telethon.helpers.TotalList>` instead.
"""
total = [0]
kwargs['_total'] = total
participants = UserList()
participants = helpers.TotalList()
async for x in self.iter_participants(*args, **kwargs):
participants.append(x)
participants.total = total[0]