pyrofork: Add join_request parameter to get_chat_members_count

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2024-07-31 11:36:09 +07:00
parent bed95d6ec2
commit f1e2b493b6
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5

View file

@ -26,7 +26,8 @@ from pyrogram import raw
class GetChatMembersCount:
async def get_chat_members_count(
self: "pyrogram.Client",
chat_id: Union[int, str]
chat_id: Union[int, str],
join_request: bool = False
) -> int:
"""Get the number of members in a chat.
@ -37,6 +38,9 @@ class GetChatMembersCount:
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
join_request (``bool``, *optional*):
If True, the count will include the number of users who sent a join request to the chat.
Returns:
``int``: On success, the chat members count is returned.
@ -57,8 +61,9 @@ class GetChatMembersCount:
id=[peer.chat_id]
)
)
return r.chats[0].participants_count
if not join_request:
return r.chats[0].participants_count
return r.chats[0].requests_pending
elif isinstance(peer, raw.types.InputPeerChannel):
r = await self.invoke(
raw.functions.channels.GetFullChannel(
@ -66,6 +71,8 @@ class GetChatMembersCount:
)
)
return r.full_chat.participants_count
if not join_request:
return r.full_chat.participants_count
return r.full_chat.requests_pending
else:
raise ValueError(f'The chat_id "{chat_id}" belongs to a user')