From 9bb83e931989255b82afd8889fd11f7038c6da0a Mon Sep 17 00:00:00 2001 From: Devesh Pal <69723581+New-dev0@users.noreply.github.com> Date: Fri, 16 Jul 2021 21:31:27 -0300 Subject: [PATCH] Add bound method `stop()` to the `Poll` object Signed-off-by: wulan17 --- pyrogram/types/messages_and_media/poll.py | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pyrogram/types/messages_and_media/poll.py b/pyrogram/types/messages_and_media/poll.py index cdb97ea1..10a10e44 100644 --- a/pyrogram/types/messages_and_media/poll.py +++ b/pyrogram/types/messages_and_media/poll.py @@ -201,3 +201,40 @@ class Poll(Object, Update): correct_option_id=correct_option_id, client=client ) + + async def stop( + self, + reply_markup: "types.InlineKeyboardMarkup" = None + ) -> "types.Poll": + """Bound method *stop* of :obj:`~pyrogram.types.Poll`. + + Use as a shortcut for: + + .. code-block:: python + + client.stop_poll( + chat_id=message.chat.id, + message_id=message.id, + ) + + Parameters: + reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*): + An InlineKeyboardMarkup object. + + Example: + .. code-block:: python + + message.poll.stop() + + Returns: + :obj:`~pyrogram.types.Poll`: On success, the stopped poll with the final results is returned. + + Raises: + RPCError: In case of a Telegram RPC error. + """ + + return await self._client.stop_poll( + chat_id=self.chat.id, + message_id=self.id, + reply_markup=reply_markup + )