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

Update send_poll to allow multiple answers, public voting and quiz

This commit is contained in:
Dan 2020-02-01 15:19:52 +01:00
parent d3e9816b24
commit 88f681f0fd

View File

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