Skip to content

Add support for Bot API version 9.5#2566

Open
KimmyXYC wants to merge 4 commits intoeternnoir:masterfrom
KimmyXYC:master
Open

Add support for Bot API version 9.5#2566
KimmyXYC wants to merge 4 commits intoeternnoir:masterfrom
KimmyXYC:master

Conversation

@KimmyXYC
Copy link

@KimmyXYC KimmyXYC commented Mar 1, 2026

Description

Include changes, new features and etc:

  • Added Bot API 9.5 support for MessageEntity type date_time with fields unix_time and date_time_format.
  • Added sendMessageDraft support for both sync and async clients/helpers.
  • Added tag to ChatMemberMember and ChatMemberRestricted.
  • Added setChatMemberTag method for both sync and async clients/helpers.
  • Added can_edit_tag to ChatMemberRestricted and ChatPermissions.
  • Added can_manage_tags to ChatMemberAdministrator and ChatAdministratorRights.
  • Added can_manage_tags parameter support in promoteChatMember (sync + async).
  • Added sender_tag support in Message.
  • Updated MessageEntity.unix_time docstring wording to match Bot API spec (Unix time associated with the entity).
  • Intentionally did not implement BottomButton.iconCustomEmojiId in this PR.

Describe your tests

How did you test your change?

  • Added/updated unit tests for new 9.5 types/fields and API helper methods:
    • tests/test_types.py:
      • test_message_entity_date_time
      • test_message_sender_tag
      • test_chat_member_member_tag
      • test_chat_member_restricted_tag_and_can_edit_tag
      • test_chat_member_administrator_can_manage_tags
      • test_chat_permissions_can_edit_tag
      • test_chat_administrator_rights_can_manage_tags
    • tests/test_apihelper_95.py:
      • test_promote_chat_member_can_manage_tags
      • test_set_chat_member_tag
  • Verified code paths exist for both sync and async layers (telebot/__init__.py, telebot/async_telebot.py, telebot/apihelper.py, telebot/asyncio_helper.py).

Python version: 3.12

OS: Windows 11

Checklist:

  • I added/edited example on new feature/change (if exists)
  • My changes won't break backward compatibility
  • I made changes both for sync and async

Copilot AI review requested due to automatic review settings March 1, 2026 13:16
Copy link
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

Adds Telegram Bot API 9.5 support across types, sync/async clients, helpers, tests, and examples to keep the library aligned with the latest API surface.

Changes:

  • Extend core types with Bot API 9.5 fields (e.g., MessageEntity.date_time, sender/member tag fields, new permissions/rights flags).
  • Add new helper/client methods (setChatMemberTag) and support new promotion flag (can_manage_tags) in promoteChatMember (sync + async).
  • Update/expand unit tests and examples; bump README supported Bot API version badge/link.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
telebot/types.py Adds new 9.5 fields on message entities, messages, chat members, permissions, and admin rights.
telebot/apihelper.py Adds set_chat_member_tag and can_manage_tags support to promote_chat_member.
telebot/asyncio_helper.py Async equivalents for set_chat_member_tag and promote_chat_member(can_manage_tags=...).
telebot/__init__.py Exposes new/updated APIs on the synchronous TeleBot client.
telebot/async_telebot.py Exposes new/updated APIs on the async client and updates docstrings.
tests/test_types.py Adds unit tests for new 9.5 fields across types.
tests/test_apihelper_95.py Adds unit tests for new helper params/methods (can_manage_tags, set_chat_member_tag).
examples/send_message_draft_example.py New sync example for send_message_draft.
examples/asynchronous_telebot/send_message_draft_example.py New async example for send_message_draft.
examples/formatting_example.py Adds a date_time entity usage example (sync).
examples/asynchronous_telebot/formatting_example.py Adds a date_time entity usage example (async).
examples/chat_member_example.py Adds a set_tag command example (sync).
examples/asynchronous_telebot/chat_member_example.py Adds a set_tag command example (async).
README.md Updates supported Bot API version badge/link to 9.5.

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

@Badiboy
Copy link
Collaborator

Badiboy commented Mar 1, 2026

Thank you, we'll review in the nearest days.

@KimmyXYC
Copy link
Author

KimmyXYC commented Mar 6, 2026

Hi! 👋

Just a gentle follow-up on this PR.
Please let me know if there’s anything I should change or improve.

Thanks for your time!

:return: True on success.
:rtype: :obj:`bool`
"""
return apihelper.set_chat_member_tag(self.token, chat_id, user_id, tag)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better pass optional parameters using parameter names; tag=tag

@coder2020official
Copy link
Collaborator

Otherwise lgtm. No opinion on the new tests implemented

@KimmyXYC
Copy link
Author

KimmyXYC commented Mar 6, 2026

Otherwise lgtm. No opinion on the new tests implemented

Thanks for the review! I've updated the code to pass the optional parameter as a named argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants