From 88f681f0fd53d40ac0f6ad8eafb5c8710e410fb8 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 1 Feb 2020 15:19:52 +0100 Subject: [PATCH] Update send_poll to allow multiple answers, public voting and quiz --- pyrogram/client/methods/messages/send_poll.py | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/methods/messages/send_poll.py b/pyrogram/client/methods/messages/send_poll.py index d26d32ca..57cbf535 100644 --- a/pyrogram/client/methods/messages/send_poll.py +++ b/pyrogram/client/methods/messages/send_poll.py @@ -29,6 +29,10 @@ class SendPoll(BaseClient): chat_id: Union[int, str], question: str, options: List[str], + is_anonymous: bool = True, + allows_multiple_answers: bool = None, + type: str = "regular", + correct_option_id: int = None, disable_notification: bool = None, reply_to_message_id: int = None, schedule_date: int = None, @@ -53,6 +57,22 @@ class SendPoll(BaseClient): options (List of ``str``): List of answer options, 2-10 strings 1-100 characters each. + is_anonymous (``bool``, *optional*): + True, if the poll needs to be anonymous. + Defaults to True. + + type (``str``, *optional*): + Poll type, "quiz" or "regular". + Defaults to "regular" + + allows_multiple_answers (``bool``, *optional*): + True, if the poll allows multiple answers, ignored for polls in quiz mode. + Defaults to False + + correct_option_id (``int``, *optional*): + 0-based identifier of the correct answer option (the index of the correct option) + Required for polls in quiz mode. + disable_notification (``bool``, *optional*): Sends the message silently. Users will receive a notification with no sound. @@ -85,8 +105,12 @@ class SendPoll(BaseClient): answers=[ types.PollAnswer(text=o, option=bytes([i])) for i, o in enumerate(options) - ] - ) + ], + multiple_choice=allows_multiple_answers or None, + public_voters=not is_anonymous or None, + quiz=type == "quiz" or None + ), + correct_answers=[bytes([correct_option_id])] if correct_option_id else None ), message="", silent=disable_notification or None,