mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-06 21:20:22 +03:00
things
This commit is contained in:
parent
2953d4cc0c
commit
dfd25186cd
|
@ -1014,27 +1014,26 @@ class TelegramClient(TelegramBareClient):
|
||||||
|
|
||||||
raise TypeError('Invalid message type: {}'.format(type(message)))
|
raise TypeError('Invalid message type: {}'.format(type(message)))
|
||||||
|
|
||||||
def get_participants(self, entity, search='', limit=None):
|
def get_participants(self, entity, limit=None, search=''):
|
||||||
"""
|
"""
|
||||||
Gets the list of participants from the specified entity
|
Gets the list of participants from the specified entity
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
entity (:obj:`entity`):
|
entity (:obj:`entity`):
|
||||||
The entity from which to retrieve the participants list
|
The entity from which to retrieve the participants list.
|
||||||
|
|
||||||
search (:obj: `str`):
|
|
||||||
Look for participants with this string in name/username etc.
|
|
||||||
|
|
||||||
limit (:obj: `int`):
|
limit (:obj: `int`):
|
||||||
Limits amount of participants fetched
|
Limits amount of participants fetched.
|
||||||
|
|
||||||
|
search (:obj: `str`, optional):
|
||||||
|
Look for participants with this string in name/username.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A list of participants with an additional .count variable on the list.
|
A list of participants with an additional .total variable on the list
|
||||||
|
indicating the total amount of members in this group/channel.
|
||||||
"""
|
"""
|
||||||
entity = self.get_input_entity(entity)
|
entity = self.get_input_entity(entity)
|
||||||
|
|
||||||
limit = float('inf') if limit is None else int(limit)
|
limit = float('inf') if limit is None else int(limit)
|
||||||
|
|
||||||
if isinstance(entity, InputPeerChannel):
|
if isinstance(entity, InputPeerChannel):
|
||||||
offset = 0
|
offset = 0
|
||||||
all_participants = {}
|
all_participants = {}
|
||||||
|
@ -1054,18 +1053,20 @@ class TelegramClient(TelegramBareClient):
|
||||||
break
|
break
|
||||||
users = UserList(all_participants.values())
|
users = UserList(all_participants.values())
|
||||||
if limit <= 200:
|
if limit <= 200:
|
||||||
users.count = self(GetFullChannelRequest(entity)).full_chat.participants_count
|
users.total = \
|
||||||
|
self(GetFullChannelRequest(entity)).full_chat.participants_count
|
||||||
else:
|
else:
|
||||||
users.count = participants.count # returns incorrect amount if limit <= 200
|
# Returns incorrect amount unless limit > 200
|
||||||
|
users.total = participants.count
|
||||||
elif isinstance(entity, InputPeerChat):
|
elif isinstance(entity, InputPeerChat):
|
||||||
users = self(GetFullChatRequest(entity.chat_id)).users
|
users = self(GetFullChatRequest(entity.chat_id)).users
|
||||||
if len(users) > limit:
|
if len(users) > limit:
|
||||||
users = users[:limit]
|
users = users[:limit]
|
||||||
users = UserList(users)
|
users = UserList(users)
|
||||||
users.count = len(users)
|
users.total = len(users)
|
||||||
else: # must be a user?
|
else:
|
||||||
users = UserList([entity])
|
users = UserList([entity])
|
||||||
users.count = 1
|
users.total = 1
|
||||||
return users
|
return users
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
Loading…
Reference in New Issue
Block a user