Rework vote_poll to work with all polls generated by different clients

This commit is contained in:
Dan 2018-12-23 16:30:42 +01:00
parent 1f82eaa26f
commit 10f1e06326
2 changed files with 7 additions and 2 deletions

View File

@ -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]
)
)

View File

@ -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
))