Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/unreleased/5196.7keq7yJhXbMb9RyShLHz4D.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ features = "Full Support for Bot API 9.6"

pull_requests = [
{ uid = "5196", author_uid = "harshil21" },
{ uid = "5202", author_uid = "ouyooung" },
]
11 changes: 10 additions & 1 deletion src/telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@
"Poll",
"PollAnswer",
"PollOption",
"PollOptionAdded",
"PollOptionDeleted",
"PreCheckoutQuery",
"PreparedInlineMessage",
"ProximityAlertTriggered",
Expand Down Expand Up @@ -564,7 +566,14 @@
RevenueWithdrawalStateSucceeded,
)
from ._payment.successfulpayment import SuccessfulPayment
from ._poll import InputPollOption, Poll, PollAnswer, PollOption
from ._poll import (
InputPollOption,
Poll,
PollAnswer,
PollOption,
PollOptionAdded,
PollOptionDeleted,
)
from ._proximityalerttriggered import ProximityAlertTriggered
from ._reaction import (
ReactionCount,
Expand Down
53 changes: 52 additions & 1 deletion src/telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
from telegram._utils.types import (
BaseUrl,
CorrectOptionID,
CorrectOptionIds,
FileInput,
JSONDict,
ODVInput,
Expand Down Expand Up @@ -7596,9 +7597,17 @@ async def send_poll(
options: Sequence["str | InputPollOption"],
is_anonymous: bool | None = None,
type: str | None = None, # pylint: disable=redefined-builtin
allows_multiple_answers: bool | None = None,
correct_option_id: CorrectOptionID | None = None,
allows_multiple_answers: bool | None = None,
allows_revoting: bool | None = None,
allow_adding_options: bool | None = None,
hide_results_until_closes: bool | None = None,
correct_option_ids: CorrectOptionIds | None = None,
is_closed: bool | None = None,
description: str | None = None,
description_parse_mode: str | None = None,
description_entities: Sequence["MessageEntity"] | None = None,
shuffle_options: bool | None = None,
Comment on lines +7601 to +7610
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same thing I said about the parameters in extbot.py applies here too.

disable_notification: ODVInput[bool] = DEFAULT_NONE,
reply_markup: "ReplyMarkup | None" = None,
explanation: str | None = None,
Expand Down Expand Up @@ -7652,6 +7661,25 @@ async def send_poll(
multiple answers, ignored for polls in quiz mode, defaults to :obj:`False`.
correct_option_id (:obj:`int`, optional): 0-based identifier of the correct answer
option, required for polls in quiz mode.
allows_revoting (:obj:`bool`, optional): :obj:`True`, if the poll allows to
change the chosen answer options, defaults to :obj:`False` for quizzes and to :obj:`True` for regular polls

.. versionadded:: NEXT.VERSION
allow_adding_options (:obj:`bool`, optional): :obj:`True`, if answer options can be
added to the poll after creation; not supported for anonymous polls and quizzes

.. versionadded:: NEXT.VERSION
shuffle_options (:obj:`bool`, optional): :obj:`True`, if the poll options must be
shown in random order

.. versionadded:: NEXT.VERSION
hide_results_until_closes (:obj:`bool`, optional): :obj:`True`, if poll results
must be shown only after the poll closes

.. versionadded:: NEXT.VERSION
correct_option_ids (Sequence[:class:`int`], optional): A list of monotonically increasing 0-based identifiers of the correct answer options, required for polls in quiz mode.

.. versionadded:: NEXT.VERSION
Comment on lines +7664 to +7682
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these new documentation should be after the allow_paid_broadcast docstring.

explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect
answer or taps on the lamp icon in a quiz-style poll,
0-:tg-const:`telegram.Poll.MAX_EXPLANATION_LENGTH` characters with at most
Expand Down Expand Up @@ -7682,6 +7710,21 @@ async def send_poll(
|tz-naive-dtms|
is_closed (:obj:`bool`, optional): Pass :obj:`True`, if the poll needs to be
immediately closed. This can be useful for poll preview.
description (:obj:`str`, optional): Description of the poll to be sent,
0-:tg-const:`telegram.Poll.MAX_DESCRIPTION_CHARACTERS` characters
after entities parsing.

.. versionadded:: NEXT.VERSION
description_parse_mode (:obj:`str`, optional): Mode for parsing entities
in the poll description. See the constants
in :class:`telegram.constants.ParseMode`

.. versionadded:: NEXT.VERSION
description_entities (Sequence[:class:`telegram.MessageEntity`], optional): A
JSON-serialized list of special entities that appear in the poll description,
which can be specified instead of :paramref:`description_parse_mode`

.. versionadded:: NEXT.VERSION
disable_notification (:obj:`bool`, optional): |disable_notification|
protect_content (:obj:`bool`, optional): |protect_content|

Expand Down Expand Up @@ -7756,7 +7799,15 @@ async def send_poll(
"type": type,
"allows_multiple_answers": allows_multiple_answers,
"correct_option_id": correct_option_id,
"allow_adding_options": allow_adding_options,
"allows_revoting": allows_revoting,
"shuffle_options": shuffle_options,
"hide_results_until_closes": hide_results_until_closes,
"correct_option_ids": correct_option_ids,
"is_closed": is_closed,
"description": description,
"description_parse_mode": description_parse_mode,
"description_entities": description_entities,
"explanation": explanation,
"explanation_entities": explanation_entities,
"open_period": open_period,
Expand Down
19 changes: 18 additions & 1 deletion src/telegram/_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import (
CorrectOptionID,
CorrectOptionIds,
FileInput,
JSONDict,
ODVInput,
Expand Down Expand Up @@ -2296,9 +2297,17 @@ async def send_poll(
question_entities: Sequence["MessageEntity"] | None = None,
message_effect_id: str | None = None,
allow_paid_broadcast: bool | None = None,
shuffle_options: bool | None = None,
allows_revoting: bool | None = None,
correct_option_ids: CorrectOptionIds | None = None,
allow_adding_options: bool | None = None,
hide_results_until_closes: bool | None = None,
description: str | None = None,
description_parse_mode: str | None = None,
description_entities: Sequence["MessageEntity"] | None = None,
*,
reply_to_message_id: int | None = None,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this too

allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int | None = None,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
Expand All @@ -2323,6 +2332,9 @@ async def send_poll(
type=type, # pylint=pylint,
allows_multiple_answers=allows_multiple_answers,
correct_option_id=correct_option_id,
allows_revoting=allows_revoting,
shuffle_options=shuffle_options,
correct_option_ids=correct_option_ids,
is_closed=is_closed,
disable_notification=disable_notification,
reply_to_message_id=reply_to_message_id,
Expand All @@ -2346,6 +2358,11 @@ async def send_poll(
business_connection_id=business_connection_id,
question_parse_mode=question_parse_mode,
question_entities=question_entities,
description=description,
description_parse_mode=description_parse_mode,
description_entities=description_entities,
hide_results_until_closes=hide_results_until_closes,
allow_adding_options=allow_adding_options,
)

async def send_copy(
Expand Down
60 changes: 55 additions & 5 deletions src/telegram/_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
from telegram._payment.invoice import Invoice
from telegram._payment.refundedpayment import RefundedPayment
from telegram._payment.successfulpayment import SuccessfulPayment
from telegram._poll import Poll
from telegram._poll import Poll, PollOptionAdded, PollOptionDeleted
from telegram._proximityalerttriggered import ProximityAlertTriggered
from telegram._reply import ReplyParameters
from telegram._shared import ChatShared, UsersShared
Expand All @@ -80,6 +80,7 @@
from telegram._utils.strings import TextEncoding
from telegram._utils.types import (
CorrectOptionID,
CorrectOptionIds,
JSONDict,
MarkdownVersion,
ODVInput,
Expand Down Expand Up @@ -689,6 +690,18 @@ class Message(MaybeInaccessibleMessage):
supergroups only

.. versionadded:: 22.7
poll_option_added (:class:`telegram.PollOptionAdded`, optional): Service message:
answer option was added to a poll.

.. versionadded:: NEXT.VERSION
poll_option_deleted (:class:`telegram.PollOptionDeleted`, optional): Service message:
answer option was deleted from a poll.

.. versionadded:: NEXT.VERSION
reply_to_poll_option_id (:obj:`str`, optional): Persistent
identifier of the specific poll option that is being replied to.

.. versionadded:: NEXT.VERSION

Attributes:
message_id (:obj:`int`): Unique message identifier inside this chat. In specific instances
Expand Down Expand Up @@ -1105,6 +1118,18 @@ class Message(MaybeInaccessibleMessage):
supergroups only

.. versionadded:: 22.7
poll_option_added (:class:`telegram.PollOptionAdded`): Optional. Service message:
answer option was added to a poll.

.. versionadded:: NEXT.VERSION
poll_option_deleted (:class:`telegram.PollOptionDeleted`): Optional. Service message:
answer option was deleted from a poll.

.. versionadded:: NEXT.VERSION
reply_to_poll_option_id (:obj:`str`): Optional. Persistent
identifier of the specific poll option that is being replied to.

.. versionadded:: NEXT.VERSION

.. |custom_emoji_no_md1_support| replace:: Since custom emoji entities are not supported by
:attr:`~telegram.constants.ParseMode.MARKDOWN`, this method now raises a
Expand Down Expand Up @@ -1191,12 +1216,15 @@ class Message(MaybeInaccessibleMessage):
"photo",
"pinned_message",
"poll",
"poll_option_added",
"poll_option_deleted",
"proximity_alert_triggered",
"quote",
"refunded_payment",
"reply_markup",
"reply_to_checklist_task_id",
"reply_to_message",
"reply_to_poll_option_id",
"reply_to_story",
"sender_boost_count",
"sender_business_bot",
Expand Down Expand Up @@ -1315,6 +1343,8 @@ def __init__(
effect_id: str | None = None,
show_caption_above_media: bool | None = None,
paid_media: PaidMediaInfo | None = None,
poll_option_added: PollOptionAdded | None = None,
poll_option_deleted: PollOptionDeleted | None = None,
Comment on lines +1346 to +1347
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these parameters should be added after sender_tag, otherwise it's breaking.

refunded_payment: RefundedPayment | None = None,
gift: GiftInfo | None = None,
unique_gift: UniqueGiftInfo | None = None,
Expand All @@ -1337,6 +1367,7 @@ def __init__(
chat_owner_changed: ChatOwnerChanged | None = None,
chat_owner_left: ChatOwnerLeft | None = None,
sender_tag: str | None = None,
reply_to_poll_option_id: str | None = None,
*,
api_kwargs: JSONDict | None = None,
):
Expand Down Expand Up @@ -1467,6 +1498,9 @@ def __init__(
self.chat_owner_changed: ChatOwnerChanged | None = chat_owner_changed
self.chat_owner_left: ChatOwnerLeft | None = chat_owner_left
self.sender_tag: str | None = sender_tag
self.poll_option_added: PollOptionAdded | None = poll_option_added
self.poll_option_deleted: PollOptionDeleted | None = poll_option_deleted
self.reply_to_poll_option_id: str | None = reply_to_poll_option_id

self._effective_attachment = DEFAULT_NONE

Expand Down Expand Up @@ -3464,24 +3498,32 @@ async def reply_poll(
explanation: str | None = None,
explanation_parse_mode: ODVInput[str] = DEFAULT_NONE,
open_period: TimePeriod | None = None,
close_date: int | (dtm.datetime | None) = None,
close_date: int | dtm.datetime | None = None,
explanation_entities: Sequence["MessageEntity"] | None = None,
protect_content: ODVInput[bool] = DEFAULT_NONE,
message_thread_id: ODVInput[int] = DEFAULT_NONE,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert this change

message_thread_id: int | None = None,
reply_parameters: "ReplyParameters | None" = None,
question_parse_mode: ODVInput[str] = DEFAULT_NONE,
question_entities: Sequence["MessageEntity"] | None = None,
message_effect_id: str | None = None,
allow_paid_broadcast: bool | None = None,
shuffle_options: bool | None = None,
allows_revoting: bool | None = None,
correct_option_ids: CorrectOptionIds | None = None,
allow_adding_options: bool | None = None,
hide_results_until_closes: bool | None = None,
description: str | None = None,
description_parse_mode: str | None = None,
description_entities: Sequence["MessageEntity"] | None = None,
*,
reply_to_message_id: int | None = None,
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
do_quote: bool | (_ReplyKwargs | None) = None,
Comment on lines -3477 to -3479
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert these changes

reply_to_message_id: int | None = None,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict | None = None,
do_quote: bool | (_ReplyKwargs | None) = None,
) -> "Message":
"""Shortcut for::

Expand Down Expand Up @@ -3522,6 +3564,9 @@ async def reply_poll(
type=type,
allows_multiple_answers=allows_multiple_answers,
correct_option_id=correct_option_id,
allows_revoting=allows_revoting,
shuffle_options=shuffle_options,
correct_option_ids=correct_option_ids,
is_closed=is_closed,
disable_notification=disable_notification,
reply_parameters=effective_reply_parameters,
Expand All @@ -3543,6 +3588,11 @@ async def reply_poll(
question_entities=question_entities,
message_effect_id=message_effect_id,
allow_paid_broadcast=allow_paid_broadcast,
description=description,
description_parse_mode=description_parse_mode,
description_entities=description_entities,
hide_results_until_closes=hide_results_until_closes,
allow_adding_options=allow_adding_options,
)

async def reply_dice(
Expand Down
Loading
Loading