From 10f1e063269438b720531bc4d31552b8803d951c Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 23 Dec 2018 16:30:42 +0100 Subject: [PATCH] Rework vote_poll to work with all polls generated by different clients --- pyrogram/client/methods/messages/vote_poll.py | 4 +++- pyrogram/client/types/messages_and_media/poll.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/methods/messages/vote_poll.py b/pyrogram/client/methods/messages/vote_poll.py index 06b45d13..fcb3932f 100644 --- a/pyrogram/client/methods/messages/vote_poll.py +++ b/pyrogram/client/methods/messages/vote_poll.py @@ -28,11 +28,13 @@ class VotePoll(BaseClient): chat_id: Union[int, str], message_id: id, option: int) -> bool: + poll = self.get_messages(chat_id, message_id).poll + self.send( functions.messages.SendVote( peer=self.resolve_peer(chat_id), msg_id=message_id, - options=[bytes([option])] + options=[poll.options[option]._data] ) ) diff --git a/pyrogram/client/types/messages_and_media/poll.py b/pyrogram/client/types/messages_and_media/poll.py index a7277f49..42ba8640 100644 --- a/pyrogram/client/types/messages_and_media/poll.py +++ b/pyrogram/client/types/messages_and_media/poll.py @@ -28,11 +28,13 @@ class PollOption(PyrogramType): *, client: "pyrogram.client.ext.BaseClient", text: str, - voters: int): + voters: int, + data: bytes): super().__init__(client) self.text = text self.voters = voters + self._data = data class Poll(PyrogramType): @@ -76,6 +78,7 @@ class Poll(PyrogramType): options.append(PollOption( text=answer.text, voters=voters, + data=answer.option, client=client ))