2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Update vote_poll to allow voting for multiple options

This commit is contained in:
Dan 2020-02-01 15:21:35 +01:00
parent 88f681f0fd
commit aa1c0e226e

View File

@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from typing import Union
from typing import Union, List
import pyrogram
from pyrogram.api import functions
@ -28,7 +28,7 @@ class VotePoll(BaseClient):
self,
chat_id: Union[int, str],
message_id: id,
option: int
options: Union[int, List[int]]
) -> "pyrogram.Poll":
"""Vote a poll.
@ -41,8 +41,8 @@ class VotePoll(BaseClient):
message_id (``int``):
Identifier of the original message with the poll.
option (``int``):
Index of the poll option you want to vote for (0 to 9).
options (``Int`` | List of ``int``):
Index or list of indexes (for multiple answers) of the poll option(s) you want to vote for (0 to 9).
Returns:
:obj:`Poll` - On success, the poll with the chosen option is returned.
@ -54,12 +54,13 @@ class VotePoll(BaseClient):
"""
poll = self.get_messages(chat_id, message_id).poll
options = [options] if not isinstance(options, list) else options
r = self.send(
functions.messages.SendVote(
peer=self.resolve_peer(chat_id),
msg_id=message_id,
options=[poll.options[option]._data]
options=[poll.options[option].data for option in options]
)
)