Skip to content

Commit d7c2423

Browse files
authored
feat: update reply_poll and answer_poll with media support (#311)
1 parent a4e3e1c commit d7c2423

1 file changed

Lines changed: 61 additions & 15 deletions

File tree

pyrogram/types/messages_and_media/message.py

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5121,22 +5121,26 @@ async def answer_photo(
51215121
async def reply_poll(
51225122
self,
51235123
question: "types.FormattedText",
5124-
options: List[Union[str, "types.FormattedText"]],
5124+
options: List[Union[str, "types.InputPollOption"]],
5125+
description: Optional["types.FormattedText"] = None,
5126+
description_media: Optional["types.InputPollMedia"] = None,
51255127
message_thread_id: Optional[int] = None,
51265128
business_connection_id: Optional[str] = None,
51275129
is_anonymous: bool = True,
51285130
type: "enums.PollType" = enums.PollType.REGULAR,
51295131
allows_multiple_answers: Optional[bool] = None,
51305132
allows_revoting: Optional[bool] = None,
5133+
members_only: Optional[bool] = None,
5134+
country_codes: Optional[List[str]] = None,
51315135
shuffle_options: Optional[bool] = None,
51325136
allow_adding_options: Optional[bool] = None,
51335137
hide_results_until_closes: Optional[bool] = None,
51345138
correct_option_ids: Optional[List[int]] = None,
51355139
explanation: Optional["types.FormattedText"] = None,
5140+
explanation_media: Optional["types.InputPollMedia"] = None,
51365141
open_period: Optional[int] = None,
51375142
close_date: Optional[datetime] = None,
51385143
is_closed: Optional[bool] = None,
5139-
description: Optional["types.FormattedText"] = None,
51405144
disable_notification: Optional[bool] = None,
51415145
protect_content: Optional[bool] = None,
51425146
allow_paid_broadcast: Optional[bool] = None,
@@ -5171,9 +5175,15 @@ async def reply_poll(
51715175
Poll question, 1-255 characters (up to 300 characters for bots).
51725176
Only custom emoji entities are allowed to be added and only by Premium users.
51735177
5174-
options (List of ``str`` | List of :obj:`~pyrogram.types.FormattedText`):
5178+
options (List of :obj:`~pyrogram.types.InputPollOption`):
51755179
List of 1-12 answer options, each 1-100 characters.
51765180
5181+
description (``str`` | :obj:`~pyrogram.types.FormattedText`, *optional*):
5182+
Description of the poll to be sent, 0-1024 characters after entities parsing.
5183+
5184+
description_media (:obj:`~pyrogram.types.InputPollMedia`, *optional*):
5185+
Media attached to the poll.
5186+
51775187
message_thread_id (``int``, *optional*):
51785188
Unique identifier for the target message thread (topic) of the forum.
51795189
For supergroups only.
@@ -5197,6 +5207,15 @@ async def reply_poll(
51975207
Pass True, if the poll allows to change chosen answer options.
51985208
Defaults to False for quizzes and to True for regular polls.
51995209
5210+
members_only (``bool``, *optional*):
5211+
Pass True, if voting is limited to users who have been members of the chat where the poll is being sent for more than 24 hours.
5212+
For channel chats only.
5213+
5214+
country_codes (List of ``str``, *optional*):
5215+
The list of 0-12 two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which users can vote in the poll.
5216+
For channel chats only.
5217+
If omitted or empty, then users from any country can participate in the poll.
5218+
52005219
shuffle_options (``bool``, *optional*):
52015220
Pass True, if the poll options must be shown in random order.
52025221
@@ -5212,6 +5231,9 @@ async def reply_poll(
52125231
explanation (``str`` | :obj:`~pyrogram.types.FormattedText`, *optional*):
52135232
Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing.
52145233
5234+
explanation_media (:obj:`~pyrogram.types.InputPollMedia`, *optional*):
5235+
Media attached to the explanation.
5236+
52155237
open_period (``int``, *optional*):
52165238
Amount of time in seconds the poll will be active after creation, 5-2628000.
52175239
Can't be used together with *close_date*.
@@ -5226,9 +5248,6 @@ async def reply_poll(
52265248
This can be useful for poll preview.
52275249
For bots only.
52285250
5229-
description (``str`` | :obj:`~pyrogram.types.FormattedText`, *optional*):
5230-
Description of the poll to be sent, 0-1024 characters after entities parsing.
5231-
52325251
disable_notification (``bool``, *optional*):
52335252
Sends the message silently.
52345253
Users will receive a notification with no sound.
@@ -5280,21 +5299,25 @@ async def reply_poll(
52805299
chat_id=self.chat.id,
52815300
question=question,
52825301
options=options,
5302+
description=description,
5303+
description_media=description_media,
52835304
message_thread_id=message_thread_id,
52845305
business_connection_id=business_connection_id,
52855306
is_anonymous=is_anonymous,
52865307
type=type,
52875308
allows_multiple_answers=allows_multiple_answers,
52885309
allows_revoting=allows_revoting,
5310+
members_only=members_only,
5311+
country_codes=country_codes,
52895312
shuffle_options=shuffle_options,
52905313
allow_adding_options=allow_adding_options,
52915314
hide_results_until_closes=hide_results_until_closes,
52925315
correct_option_ids=correct_option_ids,
52935316
explanation=explanation,
5317+
explanation_media=explanation_media,
52945318
open_period=open_period,
52955319
close_date=close_date,
52965320
is_closed=is_closed,
5297-
description=description,
52985321
disable_notification=disable_notification,
52995322
protect_content=protect_content,
53005323
allow_paid_broadcast=allow_paid_broadcast,
@@ -5309,22 +5332,26 @@ async def reply_poll(
53095332
async def answer_poll(
53105333
self,
53115334
question: "types.FormattedText",
5312-
options: List["types.FormattedText"],
5335+
options: List[Union[str, "types.InputPollOption"]],
5336+
description: Optional["types.FormattedText"] = None,
5337+
description_media: Optional["types.InputPollMedia"] = None,
53135338
message_thread_id: Optional[int] = None,
53145339
business_connection_id: Optional[str] = None,
53155340
is_anonymous: bool = True,
53165341
type: "enums.PollType" = enums.PollType.REGULAR,
53175342
allows_multiple_answers: Optional[bool] = None,
53185343
allows_revoting: Optional[bool] = None,
5344+
members_only: Optional[bool] = None,
5345+
country_codes: Optional[List[str]] = None,
53195346
shuffle_options: Optional[bool] = None,
53205347
allow_adding_options: Optional[bool] = None,
53215348
hide_results_until_closes: Optional[bool] = None,
53225349
correct_option_ids: Optional[List[int]] = None,
53235350
explanation: Optional["types.FormattedText"] = None,
5351+
explanation_media: Optional["types.InputPollMedia"] = None,
53245352
open_period: Optional[int] = None,
53255353
close_date: Optional[datetime] = None,
53265354
is_closed: Optional[bool] = None,
5327-
description: Optional["types.FormattedText"] = None,
53285355
disable_notification: Optional[bool] = None,
53295356
protect_content: Optional[bool] = None,
53305357
allow_paid_broadcast: Optional[bool] = None,
@@ -5351,16 +5378,22 @@ async def answer_poll(
53515378
Example:
53525379
.. code-block:: python
53535380
5354-
await message.reply_poll("This is a poll", ["A", "B", "C"])
5381+
await message.answer_poll("This is a poll", ["A", "B", "C"])
53555382
53565383
Parameters:
53575384
question (``str`` | :obj:`~pyrogram.types.FormattedText`):
53585385
Poll question, 1-255 characters (up to 300 characters for bots).
53595386
Only custom emoji entities are allowed to be added and only by Premium users.
53605387
5361-
options (List of ``str`` | List of :obj:`~pyrogram.types.FormattedText`):
5388+
options (List of :obj:`~pyrogram.types.InputPollOption`):
53625389
List of 1-12 answer options, each 1-100 characters.
53635390
5391+
description (``str`` | :obj:`~pyrogram.types.FormattedText`, *optional*):
5392+
Description of the poll to be sent, 0-1024 characters after entities parsing.
5393+
5394+
description_media (:obj:`~pyrogram.types.InputPollMedia`, *optional*):
5395+
Media attached to the poll.
5396+
53645397
message_thread_id (``int``, *optional*):
53655398
Unique identifier for the target message thread (topic) of the forum.
53665399
For supergroups only.
@@ -5384,6 +5417,15 @@ async def answer_poll(
53845417
Pass True, if the poll allows to change chosen answer options.
53855418
Defaults to False for quizzes and to True for regular polls.
53865419
5420+
members_only (``bool``, *optional*):
5421+
Pass True, if voting is limited to users who have been members of the chat where the poll is being sent for more than 24 hours.
5422+
For channel chats only.
5423+
5424+
country_codes (List of ``str``, *optional*):
5425+
The list of 0-12 two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which users can vote in the poll.
5426+
For channel chats only.
5427+
If omitted or empty, then users from any country can participate in the poll.
5428+
53875429
shuffle_options (``bool``, *optional*):
53885430
Pass True, if the poll options must be shown in random order.
53895431
@@ -5399,6 +5441,9 @@ async def answer_poll(
53995441
explanation (``str`` | :obj:`~pyrogram.types.FormattedText`, *optional*):
54005442
Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing.
54015443
5444+
explanation_media (:obj:`~pyrogram.types.InputPollMedia`, *optional*):
5445+
Media attached to the explanation.
5446+
54025447
open_period (``int``, *optional*):
54035448
Amount of time in seconds the poll will be active after creation, 5-2628000.
54045449
Can't be used together with *close_date*.
@@ -5413,9 +5458,6 @@ async def answer_poll(
54135458
This can be useful for poll preview.
54145459
For bots only.
54155460
5416-
description (``str`` | :obj:`~pyrogram.types.FormattedText`, *optional*):
5417-
Description of the poll to be sent, 0-1024 characters after entities parsing.
5418-
54195461
disable_notification (``bool``, *optional*):
54205462
Sends the message silently.
54215463
Users will receive a notification with no sound.
@@ -5462,21 +5504,25 @@ async def answer_poll(
54625504
chat_id=self.chat.id,
54635505
question=question,
54645506
options=options,
5507+
description=description,
5508+
description_media=description_media,
54655509
message_thread_id=message_thread_id,
54665510
business_connection_id=business_connection_id,
54675511
is_anonymous=is_anonymous,
54685512
type=type,
54695513
allows_multiple_answers=allows_multiple_answers,
54705514
allows_revoting=allows_revoting,
5515+
members_only=members_only,
5516+
country_codes=country_codes,
54715517
shuffle_options=shuffle_options,
54725518
allow_adding_options=allow_adding_options,
54735519
hide_results_until_closes=hide_results_until_closes,
54745520
correct_option_ids=correct_option_ids,
54755521
explanation=explanation,
5522+
explanation_media=explanation_media,
54765523
open_period=open_period,
54775524
close_date=close_date,
54785525
is_closed=is_closed,
5479-
description=description,
54805526
disable_notification=disable_notification,
54815527
protect_content=protect_content,
54825528
allow_paid_broadcast=allow_paid_broadcast,

0 commit comments

Comments
 (0)