get_chat_members()#
- Client.get_chat_members()#
Get the members list of a chat.
A chat can be either a basic group, a supergroup or a channel. Requires administrator rights in channels.
Usable by Users Bots- Parameters:
chat_id (
int
|str
) – Unique identifier (int) or username (str) of the target chat.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). A query string is applicable only forSEARCH
,BANNED
andRESTRICTED
filters only.limit (
int
, optional) – Limits the number of members to be retrieved.filter (
ChatMembersFilter
, optional) – Filter used to select the kind of members you want to retrieve. Only applicable for supergroups and channels.
- Returns:
Generator
– On success, a generator yieldingChatMember
objects is returned.
Example
from pyrogram import enums # Get members async for member in app.get_chat_members(chat_id): print(member) # Get administrators administrators = [] async for m in app.get_chat_members(chat_id, filter=enums.ChatMembersFilter.ADMINISTRATORS): administrators.append(m) # Get bots bots = [] async for m in app.get_chat_members(chat_id, filter=enums.ChatMembersFilter.BOTS): bots.append(m)