From 2095f9fb5e3cf4dc39b7e5f2f51e9313a1526adb Mon Sep 17 00:00:00 2001 From: kalmengr <46006289+kalmengr@users.noreply.github.com> Date: Fri, 12 Jul 2019 12:05:19 -0400 Subject: [PATCH 1/3] Add bound method vote to Message --- .../types/messages_and_media/message.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 144f04a4..68678210 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -2923,6 +2923,43 @@ class Message(Object, Update): progress=progress, progress_args=progress_args, ) + def vote( + self, + option: int, + ) -> "Poll": + """Bound method *vote* of :obj:`Message`. + + Use as a shortcut for: + + .. code-block:: python + + client.vote_poll( + chat_id=message.chat.id, + message_id=message.message_id, + option=1 + ) + + Example: + .. code-block:: python + + message.vote(6) + + Parameters: + option (``int``): + Index of the poll option you want to vote for (0 to 9). + + Returns: + On success, the poll with the chosen option is returned. + + Raises: + RPCError: In case of a Telegram RPC error. + """ + + return self._client.vote_poll( + chat_id=self.chat.id, + message_id= self.message_id, + option=option + ) def pin(self, disable_notification: bool = None) -> "Message": """Bound method *pin* of :obj:`Message`. From ba4748814249dc003341f64b286d56449087a2b9 Mon Sep 17 00:00:00 2001 From: kalmengr <46006289+kalmengr@users.noreply.github.com> Date: Fri, 12 Jul 2019 12:13:14 -0400 Subject: [PATCH 2/3] Update message.py --- pyrogram/client/types/messages_and_media/message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 68678210..8b02839f 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -2957,7 +2957,7 @@ class Message(Object, Update): return self._client.vote_poll( chat_id=self.chat.id, - message_id= self.message_id, + message_id=self.message_id, option=option ) From 948bba7a08d4aaf14e4144d576f64ccc78069249 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 22 Jul 2019 14:16:43 +0200 Subject: [PATCH 3/3] Add missing return type --- pyrogram/client/types/messages_and_media/message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 8b02839f..ae0e257a 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -2949,7 +2949,7 @@ class Message(Object, Update): Index of the poll option you want to vote for (0 to 9). Returns: - On success, the poll with the chosen option is returned. + :obj:`Poll`: On success, the poll with the chosen option is returned. Raises: RPCError: In case of a Telegram RPC error.