Skip to content

Commit 88f681f

Browse files
committed
Update send_poll to allow multiple answers, public voting and quiz
1 parent d3e9816 commit 88f681f

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

pyrogram/client/methods/messages/send_poll.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ def send_poll(
2929
chat_id: Union[int, str],
3030
question: str,
3131
options: List[str],
32+
is_anonymous: bool = True,
33+
allows_multiple_answers: bool = None,
34+
type: str = "regular",
35+
correct_option_id: int = None,
3236
disable_notification: bool = None,
3337
reply_to_message_id: int = None,
3438
schedule_date: int = None,
@@ -53,6 +57,22 @@ def send_poll(
5357
options (List of ``str``):
5458
List of answer options, 2-10 strings 1-100 characters each.
5559
60+
is_anonymous (``bool``, *optional*):
61+
True, if the poll needs to be anonymous.
62+
Defaults to True.
63+
64+
type (``str``, *optional*):
65+
Poll type, "quiz" or "regular".
66+
Defaults to "regular"
67+
68+
allows_multiple_answers (``bool``, *optional*):
69+
True, if the poll allows multiple answers, ignored for polls in quiz mode.
70+
Defaults to False
71+
72+
correct_option_id (``int``, *optional*):
73+
0-based identifier of the correct answer option (the index of the correct option)
74+
Required for polls in quiz mode.
75+
5676
disable_notification (``bool``, *optional*):
5777
Sends the message silently.
5878
Users will receive a notification with no sound.
@@ -85,8 +105,12 @@ def send_poll(
85105
answers=[
86106
types.PollAnswer(text=o, option=bytes([i]))
87107
for i, o in enumerate(options)
88-
]
89-
)
108+
],
109+
multiple_choice=allows_multiple_answers or None,
110+
public_voters=not is_anonymous or None,
111+
quiz=type == "quiz" or None
112+
),
113+
correct_answers=[bytes([correct_option_id])] if correct_option_id else None
90114
),
91115
message="",
92116
silent=disable_notification or None,

0 commit comments

Comments
 (0)