Skip to content

Bot API 9.6#2581

Merged
Badiboy merged 21 commits intoeternnoir:masterfrom
coder2020official:master
Apr 5, 2026
Merged

Bot API 9.6#2581
Badiboy merged 21 commits intoeternnoir:masterfrom
coder2020official:master

Conversation

@coder2020official
Copy link
Copy Markdown
Collaborator

@coder2020official coder2020official commented Apr 4, 2026

Bot API 9.6

Managed Bots

Polls

  • Added support for quizzes with multiple correct answers.
  • Replaced the field correct_option_id with the field correct_option_ids in the class Poll.
  • Replaced the parameter correct_option_id with the parameter correct_option_ids in the method sendPoll.
  • Allowed to pass allows_multiple_answers for quizzes in the method sendPoll.
  • Increased the maximum time for automatic poll closure to 2628000 seconds.
  • Added the field allows_revoting to the class Poll.
  • Added the parameter allows_revoting to the method sendPoll.
  • Added the parameter shuffle_options to the method sendPoll.
  • Added the parameter allow_adding_options to the method sendPoll.
  • Added the parameter hide_results_until_closes to the method sendPoll.
  • Added the fields description and description_entities to the class Poll.
  • Added the parameters description, description_parse_mode, and description_entities to the method sendPoll.
  • Added the field persistent_id to the class PollOption, representing a persistent identifier for the option.
  • Added the field option_persistent_ids to the class PollAnswer.
  • Added the fields added_by_user and added_by_chat to the class PollOption, denoting the user and the chat which added the option.
  • Added the field addition_date to the class PollOption, describing the date when the option was added.
  • Added the class PollOptionAdded and the field poll_option_added to the class Message.
  • Added the class PollOptionDeleted and the field poll_option_deleted to the class Message.
  • Added the field poll_option_id to the class ReplyParameters, allowing bots to reply to a specific poll option.
  • Added the field reply_to_poll_option_id to the class Message.
  • Allowed “date_time” entities in checklist title, checklist task text, TextQuote, ReplyParameters quote, sendGift, and giftPremiumSubscription.

…yboardButtonRequestManagedBot and the field request_managed_bot to the class KeyboardButton.
…eir token, represented by the class ManagedBotUpdated and the field managed_bot in the class Update.
…boardButton, allowing bots to request users, chats and managed bots from Mini Apps.
…e class Message. Added the class PollOptionDeleted and the field poll_option_deleted to the class Message.
… TextQuote, ReplyParameters quote, sendGift, and giftPremiumSubscription.
@coder2020official coder2020official marked this pull request as ready for review April 5, 2026 09:02
@coder2020official
Copy link
Copy Markdown
Collaborator Author

@Badiboy I'm done, you can revidw

Please acknowledge that you received this message

@Badiboy
Copy link
Copy Markdown
Collaborator

Badiboy commented Apr 5, 2026

@coder2020official I do )
I'll review right now.

@Badiboy
Copy link
Copy Markdown
Collaborator

Badiboy commented Apr 5, 2026

@coder2020official Do you remember why we have "add" method in "Poll" class? I cannot imagine why and where it can be used as far as Poll is JsonDeserializable only..

@coder2020official
Copy link
Copy Markdown
Collaborator Author

Maybe some time ago InputPollOption never existed, and you would have to use PollOption to copy the poll..

@coder2020official
Copy link
Copy Markdown
Collaborator Author

But now it's irrelevant. To copy the poll copyMessage should be sufficient

@Badiboy
Copy link
Copy Markdown
Collaborator

Badiboy commented Apr 5, 2026

@coder2020official
It's alomost no remarks, thank you very much for this big update!!

@Badiboy Badiboy requested a review from Copilot April 5, 2026 12:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the library’s Telegram Bot API bindings to Bot API 9.6, adding support for “Managed Bots” updates/methods and the expanded Poll API fields.

Changes:

  • Added Managed Bots: new types (ManagedBotUpdated, ManagedBotCreated, KeyboardButtonRequestManagedBot, PreparedKeyboardButton) and new bot methods (getManagedBotToken, replaceManagedBotToken, savePreparedKeyboardButton) plus handler support for managed_bot updates.
  • Updated Poll model & sendPoll params for new/changed fields (e.g., correct_option_ids, allows_revoting, persistent option IDs, poll option added/deleted service messages).
  • Bumped README supported Bot API version badge to 9.6 and updated tests/fixtures accordingly.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
telebot/types.py Adds new 9.6 types and extends existing models (Update/Message/Poll/etc.).
telebot/__init__.py Adds sync bot support for managed_bot update handlers + new API methods.
telebot/async_telebot.py Adds async bot support for managed_bot update handlers + new API methods.
telebot/apihelper.py Adds sync HTTP helpers for new Bot API 9.6 methods and expanded sendPoll params.
telebot/asyncio_helper.py Adds async HTTP helpers for new Bot API 9.6 methods and expanded sendPoll params.
telebot/util.py Extends service content types for new service messages.
tests/test_types.py Updates poll/poll_answer JSON fixtures to new fields.
tests/test_telebot.py Updates Update construction to include the new managed_bot field.
tests/test_handler_backends.py Updates Update construction argument count to match new signature.
README.md Updates displayed supported Bot API version to 9.6.
Comments suppressed due to low confidence (2)

telebot/util.py:57

  • telebot.util.update_types is used as the canonical list for allowed_updates, but it doesn't include the new managed_bot update type introduced in this PR (while the bot now processes update.managed_bot). Add "managed_bot" to update_types so users can enable/disable it consistently.
    'suggested_post_paid', 'gift_upgrade_sent', 'chat_owner_left', 'chat_owner_changed', 'managed_bot_created',
    'poll_option_added', 'poll_option_deleted'
]

#: All update types, should be used for allowed_updates parameter in polling.
update_types = [
    "message", "edited_message", "channel_post", "edited_channel_post", "inline_query", "chosen_inline_result",
    "callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", "my_chat_member", "chat_member",
    "chat_join_request", "message_reaction", "message_reaction_count", "removed_chat_boost", "chat_boost",
    "business_connection", "business_message", "edited_business_message", "deleted_business_messages",
    "purchased_paid_media",
]

telebot/types.py:7726

  • PollAnswer.to_dict() sets json_dict["voter_chat"] = self.voter_chat, which is a Chat object and not JSON-serializable. This should likely be self.voter_chat.to_dict() (similar to how user is handled) to avoid runtime errors when calling to_json()/to_dict() with voter_chat present.
    def to_dict(self):
        # Left for backward compatibility, but with no support for voter_chat
        json_dict = {
            "poll_id": self.poll_id,
            "option_ids": self.option_ids,
            "option_persistent_ids": self.option_persistent_ids
        }
        if self.user:
            json_dict["user"] = self.user.to_dict()
        if self.voter_chat:
            json_dict["voter_chat"] = self.voter_chat
        return json_dict

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coder2020official
Copy link
Copy Markdown
Collaborator Author

Regarding some copilot suggestions

The API is now always passing persistent_id for polls. People using older versions of the local bot API may not receive persistent_id. Should I make it optional or prioritize the main API?

@Badiboy
Copy link
Copy Markdown
Collaborator

Badiboy commented Apr 5, 2026

The API is now always passing persistent_id for polls. People using older versions of the local bot API may not receive persistent_id. Should I make it optional or prioritize the main API?

I propose not to care about local API servers. It's a bit out of the subject of cbot library.

@Badiboy
Copy link
Copy Markdown
Collaborator

Badiboy commented Apr 5, 2026

I checked all CoPilot reviews - I confirm all you applied and all you did not, except one with "post" method.

After that I propose to merge!

@All-The-Foxes
Copy link
Copy Markdown
Contributor

managed_bot should be added to update_types in util.py

@Badiboy
Copy link
Copy Markdown
Collaborator

Badiboy commented Apr 5, 2026

Thank you!!

@Badiboy Badiboy merged commit 66ca9ea into eternnoir:master Apr 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants