From 811324b90757abaaaaa2aae93e4c69b7c1c270be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9D=E3=82=AD?= Date: Fri, 29 Jan 2021 16:46:43 +0500 Subject: [PATCH] Add missing docstrings for Chat.iter_members and .get_members (#600) --- pyrogram/types/user_and_chats/chat.py | 81 ++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py index ca5a49e6..b44e8f9d 100644 --- a/pyrogram/types/user_and_chats/chat.py +++ b/pyrogram/types/user_and_chats/chat.py @@ -791,12 +791,50 @@ class Chat(Object): client.get_chat_members(chat_id) + + Parameters: + offset (``int``, *optional*): + Sequential number of the first member to be returned. + Only applicable to supergroups and channels. Defaults to 0 [1]_. + + limit (``int``, *optional*): + Limits the number of members to be retrieved. + Only applicable to supergroups and channels. + Defaults to 200, which is also the maximum server limit allowed per method call. + + query (``str``, *optional*): + Query string to filter members based on their display names and usernames. + Only applicable to supergroups and channels. Defaults to "" (empty string) [2]_. + + filter (``str``, *optional*): + Filter used to select the kind of members you want to retrieve. Only applicable for supergroups + and channels. It can be any of the followings: + *"all"* - all kind of members, + *"kicked"* - kicked (banned) members only, + *"restricted"* - restricted members only, + *"bots"* - bots only, + *"recent"* - recent members only, + *"administrators"* - chat administrators only. + Only applicable to supergroups and channels. + Defaults to *"recent"*. + + .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members + on channels. + + .. [2] A query string is applicable only for *"all"*, *"kicked"* and *"restricted"* filters only. + Example: .. code-block:: python # Get first 200 recent members chat.get_members() + # Get all administrators + chat.get_members(filter="administrators") + + # Get all bots + chat.get_members(filter="bots") + Returns: List of :obj:`~pyrogram.types.ChatMember`: On success, a list of chat members is returned. """ @@ -821,13 +859,50 @@ class Chat(Object): .. code-block:: python - for member in client.iter_chat_members(chat_id): - print(member.user.first_name) + Parameters: + offset (``int``, *optional*): + Sequential number of the first member to be returned. + Only applicable to supergroups and channels. Defaults to 0 [1]_. + + limit (``int``, *optional*): + Limits the number of members to be retrieved. + Only applicable to supergroups and channels. + Defaults to 200, which is also the maximum server limit allowed per method call. + + query (``str``, *optional*): + Query string to filter members based on their display names and usernames. + Only applicable to supergroups and channels. Defaults to "" (empty string) [2]_. + + filter (``str``, *optional*): + Filter used to select the kind of members you want to retrieve. Only applicable for supergroups + and channels. It can be any of the followings: + *"all"* - all kind of members, + *"kicked"* - kicked (banned) members only, + *"restricted"* - restricted members only, + *"bots"* - bots only, + *"recent"* - recent members only, + *"administrators"* - chat administrators only. + Only applicable to supergroups and channels. + Defaults to *"recent"*. + + .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members + on channels. + + .. [2] A query string is applicable only for *"all"*, *"kicked"* and *"restricted"* filters only. Example: .. code-block:: python - for member in chat.iter_members(): + # Get first 200 recent members + for member in chat.get_members(): + print(member.user.first_name) + + # Get all administrators + for member in chat.iter_members(filter="administrators"): + print(member.user.first_name) + + # Get first 3 bots + for member in chat.iter_members(filter="bots", limit=3): print(member.user.first_name) Returns: