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/5] 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/5] 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 449f318e6d06dd1aeed5cd18d1533b6ef3da1aec Mon Sep 17 00:00:00 2001 From: kalmengr <46006289+kalmengr@users.noreply.github.com> Date: Fri, 12 Jul 2019 18:29:35 -0400 Subject: [PATCH 3/5] Add retract_vote bound method to Message --- .../types/messages_and_media/message.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 144f04a4..80597e33 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -2868,6 +2868,38 @@ class Message(Object, Update): raise ValueError("This button is not supported yet") else: self.reply(button, quote=quote) + + + def retract_vote( + self, + ) -> "Poll": + """Bound method *retract_vote* of :obj:`Message`. + + Use as a shortcut for: + + .. code-block:: python + + client.retract_vote( + chat_id=message.chat.id, + message_id=message_id, + ) + Example: + .. code-block:: python + + message.retract_vote() + + Returns: + :obj:`Poll` + On success, the poll with the retracted vote is returned. + + Raises: + RPCError: In case of a Telegram RPC error. + """ + + return self._client.retract_vote( + chat_id=self.chat.id, + message_id=self.message_id + ) def download( self, 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 4/5] 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. From a320088fee36cd5f7be49bef1e9ad05bf78eaf84 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 22 Jul 2019 14:21:42 +0200 Subject: [PATCH 5/5] Fix Message.retract_vote style --- pyrogram/client/types/messages_and_media/message.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 80597e33..a534aae1 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -2871,8 +2871,8 @@ class Message(Object, Update): def retract_vote( - self, - ) -> "Poll": + self, + ) -> "Poll": """Bound method *retract_vote* of :obj:`Message`. Use as a shortcut for: @@ -2883,14 +2883,14 @@ class Message(Object, Update): chat_id=message.chat.id, message_id=message_id, ) + Example: .. code-block:: python message.retract_vote() Returns: - :obj:`Poll` - On success, the poll with the retracted vote is returned. + :obj:`Poll`: On success, the poll with the retracted vote is returned. Raises: RPCError: In case of a Telegram RPC error.