mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 13:29:47 +00:00
Return helpers.TotalList instances on client.get_ methods
This commit is contained in:
@@ -38,7 +38,7 @@ class BotMethods(UserMethods):
|
||||
geo_point=geo_point
|
||||
))
|
||||
|
||||
# TODO Custom InlineResults(UserList) class with more information
|
||||
# TODO Custom InlineResults(list) class with more information
|
||||
return [
|
||||
custom.InlineResult(self, x, query_id=result.query_id)
|
||||
for x in result.results
|
||||
|
@@ -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]
|
||||
|
@@ -1,10 +1,9 @@
|
||||
import itertools
|
||||
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, custom
|
||||
|
||||
|
||||
@@ -124,12 +123,12 @@ class DialogMethods(UserMethods):
|
||||
|
||||
async def get_dialogs(self, *args, **kwargs):
|
||||
"""
|
||||
Same as :meth:`iter_dialogs`, but returns a list instead
|
||||
with an additional ``.total`` attribute on the list.
|
||||
Same as `iter_dialogs`, but returns a
|
||||
`TotalList <telethon.helpers.TotalList>` instead.
|
||||
"""
|
||||
total = [0]
|
||||
kwargs['_total'] = total
|
||||
dialogs = UserList()
|
||||
dialogs = helpers.TotalList()
|
||||
async for x in self.iter_dialogs(*args, **kwargs):
|
||||
dialogs.append(x)
|
||||
dialogs.total = total[0]
|
||||
|
@@ -2,14 +2,13 @@ import asyncio
|
||||
import itertools
|
||||
import logging
|
||||
import time
|
||||
from collections import UserList
|
||||
|
||||
from async_generator import async_generator, yield_
|
||||
|
||||
from .messageparse import MessageParseMethods
|
||||
from .uploads import UploadMethods
|
||||
from .buttons import ButtonMethods
|
||||
from .. import utils
|
||||
from .. import utils, helpers
|
||||
from ..tl import types, functions, custom
|
||||
|
||||
__log__ = logging.getLogger(__name__)
|
||||
@@ -323,8 +322,8 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
||||
|
||||
async def get_messages(self, *args, **kwargs):
|
||||
"""
|
||||
Same as :meth:`iter_messages`, but returns a list instead
|
||||
with an additional ``.total`` attribute on the list.
|
||||
Same as `iter_messages`, but returns a
|
||||
`TotalList <telethon.helpers.TotalList>` instead.
|
||||
|
||||
If the `limit` is not set, it will be 1 by default unless both
|
||||
`min_id` **and** `max_id` are set (as *named* arguments), in
|
||||
@@ -346,7 +345,7 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
||||
else:
|
||||
kwargs['limit'] = 1
|
||||
|
||||
msgs = UserList()
|
||||
msgs = helpers.TotalList()
|
||||
async for x in self.iter_messages(*args, **kwargs):
|
||||
msgs.append(x)
|
||||
msgs.total = total[0]
|
||||
|
Reference in New Issue
Block a user