Skip to content

Commit f6f6141

Browse files
committed
Add approve/decline_all_chat_join_requests
1 parent 74f970e commit f6f6141

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from typing import Union
20+
21+
import pyrogram
22+
from pyrogram import raw
23+
24+
25+
class ApproveAllChatJoinRequests:
26+
async def approve_all_chat_join_requests(
27+
self: "pyrogram.Client",
28+
chat_id: Union[int, str],
29+
invite_link: str = None
30+
) -> bool:
31+
"""Approve all pending join requests in a chat.
32+
33+
Parameters:
34+
chat_id (``int`` | ``str``):
35+
Unique identifier for the target chat or username of the target channel/supergroup
36+
(in the format @username).
37+
38+
invite_link (``str``, *optional*):
39+
Pass an invite link to approve only its join requests.
40+
By default, all join requests are approved.
41+
42+
Returns:
43+
``bool``: True on success.
44+
"""
45+
await self.invoke(
46+
raw.functions.messages.HideAllChatJoinRequests(
47+
peer=await self.resolve_peer(chat_id),
48+
approved=True,
49+
link=invite_link
50+
)
51+
)
52+
53+
return True
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from typing import Union
20+
21+
import pyrogram
22+
from pyrogram import raw
23+
24+
25+
class DeclineAllChatJoinRequests:
26+
async def decline_all_chat_join_requests(
27+
self: "pyrogram.Client",
28+
chat_id: Union[int, str],
29+
invite_link: str = None
30+
) -> bool:
31+
"""Decline all pending join requests in a chat.
32+
33+
Parameters:
34+
chat_id (``int`` | ``str``):
35+
Unique identifier for the target chat or username of the target channel/supergroup
36+
(in the format @username).
37+
38+
invite_link (``str``, *optional*):
39+
Pass an invite link to decline only its join requests.
40+
By default, all join requests are declined.
41+
42+
Returns:
43+
``bool``: True on success.
44+
"""
45+
await self.invoke(
46+
raw.functions.messages.HideAllChatJoinRequests(
47+
peer=await self.resolve_peer(chat_id),
48+
approved=False,
49+
link=invite_link
50+
)
51+
)
52+
53+
return True

0 commit comments

Comments
 (0)