From 244606eed619682ce4c089c40181e9c31c28f7e8 Mon Sep 17 00:00:00 2001 From: W4RR10R <46273006+arunpt@users.noreply.github.com> Date: Sat, 29 Jan 2022 16:06:15 +0530 Subject: [PATCH] Add approve() and decline() bound methods to ChatJoinRequest (#863) * Bound method approve() and decline() * Style fixes Co-authored-by: ArUn Pt <46273006+CW4RR10R@users.noreply.github.com> Co-authored-by: Dan <14043624+delivrance@users.noreply.github.com> --- .../types/user_and_chats/chat_join_request.py | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/pyrogram/types/user_and_chats/chat_join_request.py b/pyrogram/types/user_and_chats/chat_join_request.py index a7001da5..fe051de4 100644 --- a/pyrogram/types/user_and_chats/chat_join_request.py +++ b/pyrogram/types/user_and_chats/chat_join_request.py @@ -80,3 +80,59 @@ class ChatJoinRequest(Object, Update): invite_link=types.ChatInviteLink._parse(client, update.invite, users), client=client ) + + async def approve(self) -> bool: + """Bound method *approve* of :obj:`~pyrogram.types.ChatJoinRequest`. + + Use as a shortcut for: + + .. code-block:: python + + client.approve_chat_join_request( + chat_id=request.chat.id, + user_id=request.from_user.id + ) + + Example: + .. code-block:: python + + request.approve() + + Returns: + ``bool``: True on success. + + Raises: + RPCError: In case of a Telegram RPC error. + """ + return await self._client.approve_chat_join_request( + chat_id=self.chat.id, + user_id=self.from_user.id + ) + + async def decline(self) -> bool: + """Bound method *decline* of :obj:`~pyrogram.types.ChatJoinRequest`. + + Use as a shortcut for: + + .. code-block:: python + + client.decline_chat_join_request( + chat_id=request.chat.id, + user_id=request.from_user.id + ) + + Example: + .. code-block:: python + + request.decline() + + Returns: + ``bool``: True on success. + + Raises: + RPCError: In case of a Telegram RPC error. + """ + return await self._client.decline_chat_join_request( + chat_id=self.chat.id, + user_id=self.from_user.id + )