From f1e2b493b6051579eef4ff1108cc27a803aab95e Mon Sep 17 00:00:00 2001 From: wulan17 Date: Wed, 31 Jul 2024 11:36:09 +0700 Subject: [PATCH] pyrofork: Add join_request parameter to get_chat_members_count Signed-off-by: wulan17 --- pyrogram/methods/chats/get_chat_members_count.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pyrogram/methods/chats/get_chat_members_count.py b/pyrogram/methods/chats/get_chat_members_count.py index bc50d868..a617a72e 100644 --- a/pyrogram/methods/chats/get_chat_members_count.py +++ b/pyrogram/methods/chats/get_chat_members_count.py @@ -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/* (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')