mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-01 13:14:52 +00:00
pyrofork: Add join_request parameter to get_chat_members_count
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
bed95d6ec2
commit
f1e2b493b6
1 changed files with 11 additions and 4 deletions
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue