Skip to content

Updates to the poll section in bot API 9.6#5202

Merged
harshil21 merged 17 commits into
python-telegram-bot:api-9.6-centralfrom
ouyooung:api-9.6-polls
May 7, 2026
Merged

Updates to the poll section in bot API 9.6#5202
harshil21 merged 17 commits into
python-telegram-bot:api-9.6-centralfrom
ouyooung:api-9.6-polls

Conversation

@ouyooung

@ouyooung ouyooung commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Check-list for PRs

  • Added .. versionadded:: NEXT.VERSION, .. versionchanged:: NEXT.VERSION, .. deprecated:: NEXT.VERSION or ``.. versionremoved:: NEXT.VERSION` to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)
  • Created new or adapted existing unit tests
  • Documented code changes according to the CSI standard
  • Added myself alphabetically to AUTHORS.rst (optional)
  • Added new classes & modules to the docs and all suitable __all__ s
  • Checked the Stability Policy in case of deprecations or changes to documented behavior

If the PR contains API changes (otherwise, you can ignore this passage)

  • Checked the Bot API specific sections of the Stability Policy

  • Created a PR to remove functionality deprecated in the previous Bot API release (see here)

  • New Classes

    • Added self._id_attrs and corresponding documentation
    • __init__ accepts api_kwargs as keyword-only
  • Added New Shortcuts

    • In telegram.Chat & telegram.User for all methods that accept chat/user_id
    • In telegram.Message for all methods that accept chat_id and message_id
    • For new telegram.Message shortcuts: Added quote argument if methods accept reply_to_message_id
    • In telegram.CallbackQuery for all methods that accept either chat_id and message_id or inline_message_id
  • If Relevant

    • Added new constants at telegram.constants and shortcuts to them as class variables
    • Linked new and existing constants in docstrings instead of hard-coded numbers and strings
    • Added new message types to telegram.Message.effective_attachment
    • Added new handlers for new update types
    • Added new filters for new message (sub)types
    • Added or updated documentation for the changed class(es) and/or method(s)
    • Added the new method(s) to _extbot.py
    • Added or updated bot_methods.rst
    • Updated the Bot API version number in all places: README.rst (including the badge) and telegram.constants.BOT_API_VERSION_INFO
    • Added logic for arbitrary callback data in telegram.ext.ExtBot for new methods that either accept a reply_markup in some form or have a return type that is/contains telegram.Message

@harshil21 harshil21 left a comment

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.

Good work so far! About the deprecated things in this API update, this PR shows how we've done it in the past. Note the comments in the code which says "tags", and the warnings which are raised in the code if something deprecated is used. Can you implement that too?

Comment thread src/telegram/ext/_extbot.py
Comment thread src/telegram/_utils/types.py Outdated
Comment thread src/telegram/ext/_extbot.py Outdated
Comment thread src/telegram/ext/_extbot.py
Comment thread src/telegram/_bot.py Outdated
Comment thread src/telegram/_poll.py
Comment thread src/telegram/_poll.py Outdated
Comment thread src/telegram/_user.py
Comment thread src/telegram/constants.py Outdated
Comment thread changes/unreleased/5202.ouyoung.toml Outdated

@Poolitzer Poolitzer left a comment

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.

LGTM but dont we need a test for polloptions?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the library to match Telegram Bot API 9.6 poll-related changes by extending poll models, adding new poll service-message types, and wiring new poll parameters through bot shortcut methods and filters.

Changes:

  • Add new poll-related fields (description, allows_revoting, correct_option_ids, persistent IDs, etc.) and deprecate correct_option_id in favor of correct_option_ids.
  • Introduce PollOptionAdded/PollOptionDeleted service-message objects and add corresponding message types & filters.
  • Update tests and constants to cover the new/changed poll functionality.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/test_reply.py Extends ReplyParameters tests to cover poll_option_id.
tests/test_poll.py Adds coverage for new poll/poll option fields and new poll service-message objects.
tests/test_message.py Extends message fixture/test matrix to include new poll service-message fields.
tests/test_constants.py Updates constant/type-attribute expectations for new message fields.
tests/test_bot.py Adds test ensuring deprecated correct_option_id is mapped to correct_option_ids with a warning.
tests/ext/test_filters.py Adds tests for new filters.StatusUpdate poll-option service messages.
src/telegram/ext/filters.py Adds StatusUpdate.POLL_OPTION_ADDED/DELETED filters and includes them in StatusUpdate.ALL.
src/telegram/ext/_extbot.py Wires new Bot API 9.6 poll parameters through ExtBot.send_poll.
src/telegram/constants.py Adds new MessageType entries and updates poll limits (open period, description length).
src/telegram/_utils/types.py Introduces CorrectOptionIds typing alias for multi-answer quizzes.
src/telegram/_user.py Wires new poll parameters through User.send_poll shortcut.
src/telegram/_reply.py Documents and implements ReplyParameters.poll_option_id; updates entity allow-list wording.
src/telegram/_poll.py Extends PollOption, PollAnswer, Poll; adds PollOptionAdded/Deleted; adds parsing helpers and deprecations.
src/telegram/_message.py Adds new message fields for poll option add/delete service messages and reply-to poll option IDs; wires reply_poll params.
src/telegram/_inputchecklist.py Updates documentation wording re: allowed entities (includes date_time).
src/telegram/_chat.py Wires new poll parameters through Chat.send_poll shortcut.
src/telegram/_bot.py Adds new send_poll parameters and deprecation shim for correct_option_id.
src/telegram/init.py Exposes PollOptionAdded/PollOptionDeleted in the public API.
changes/unreleased/5196.7keq7yJhXbMb9RyShLHz4D.toml Adds PR metadata entry for this change set.

Comment thread src/telegram/_bot.py Outdated
Comment thread src/telegram/_poll.py Outdated
Comment thread src/telegram/_poll.py
Comment thread src/telegram/_poll.py
Comment thread tests/test_message.py
Comment thread src/telegram/_utils/types.py
@harshil21 harshil21 added the ⚙️ bot-api affected functionality: bot-api label May 4, 2026

@Poolitzer Poolitzer left a comment

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.

LGTM just one remark, and codecov seems to be a valid issue, do you have that in mind?

@@ -93,6 +93,11 @@

CorrectOptionID: TypeAlias = Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # pylint: disable=invalid-name

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.

should we also deprecate this?

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.

Yeah good idea. It would be a documentation note only though, having the warning on module attribute access is kinda complicated

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.

actually this module is private so it's not in the documentation anyway... skipping this entirely then.

@harshil21 harshil21 merged commit 4f36bff into python-telegram-bot:api-9.6-central May 7, 2026
25 of 27 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

⚙️ bot-api affected functionality: bot-api

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants