mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Rework vote_poll to work with all polls generated by different clients
This commit is contained in:
parent
1f82eaa26f
commit
10f1e06326
@ -28,11 +28,13 @@ class VotePoll(BaseClient):
|
|||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
message_id: id,
|
message_id: id,
|
||||||
option: int) -> bool:
|
option: int) -> bool:
|
||||||
|
poll = self.get_messages(chat_id, message_id).poll
|
||||||
|
|
||||||
self.send(
|
self.send(
|
||||||
functions.messages.SendVote(
|
functions.messages.SendVote(
|
||||||
peer=self.resolve_peer(chat_id),
|
peer=self.resolve_peer(chat_id),
|
||||||
msg_id=message_id,
|
msg_id=message_id,
|
||||||
options=[bytes([option])]
|
options=[poll.options[option]._data]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,11 +28,13 @@ class PollOption(PyrogramType):
|
|||||||
*,
|
*,
|
||||||
client: "pyrogram.client.ext.BaseClient",
|
client: "pyrogram.client.ext.BaseClient",
|
||||||
text: str,
|
text: str,
|
||||||
voters: int):
|
voters: int,
|
||||||
|
data: bytes):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.text = text
|
self.text = text
|
||||||
self.voters = voters
|
self.voters = voters
|
||||||
|
self._data = data
|
||||||
|
|
||||||
|
|
||||||
class Poll(PyrogramType):
|
class Poll(PyrogramType):
|
||||||
@ -76,6 +78,7 @@ class Poll(PyrogramType):
|
|||||||
options.append(PollOption(
|
options.append(PollOption(
|
||||||
text=answer.text,
|
text=answer.text,
|
||||||
voters=voters,
|
voters=voters,
|
||||||
|
data=answer.option,
|
||||||
client=client
|
client=client
|
||||||
))
|
))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user