Added support for Telegram Bot API 9.5 (#1780)

* Update API methods and types for Telegram Bot API 9.5

* Draft: follow-up for Bot API 9.5 (#1780) (#1781)

* Add set_chat_member_tag shortcut coverage

* Add set_member_tag shortcut tests and align decoration expectations

* Fix follow-up test coverage for sender_tag and can_edit_tag

* Add changelog fragment for PR 1781

* Align changelog with base PR #1780

* Expand 1780 changelog to cover base and follow-up scope

* Treat sender_tag as metadata, not message content type

---------

Co-authored-by: Latand <latand@users.noreply.github.com>
Co-authored-by: Codex Agent <codex@openclaw.local>

* Add tests for date_time formatting with Unix time and datetime objects

* Update changelog with Telegram Bot API 9.5 changes

---------

Co-authored-by: Kostiantyn Kriuchkov <36363097+Latand@users.noreply.github.com>
Co-authored-by: Latand <latand@users.noreply.github.com>
Co-authored-by: Codex Agent <codex@openclaw.local>
This commit is contained in:
Alex Root Junior 2026-03-03 01:19:11 +02:00 committed by GitHub
parent 73710acb4c
commit f68c24d620
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 872 additions and 79 deletions

View file

@ -6,6 +6,11 @@ class TestPromoteChatMember:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(PromoteChatMember, ok=True, result=True)
response: bool = await bot.promote_chat_member(chat_id=-42, user_id=42)
bot.get_request()
response: bool = await bot.promote_chat_member(
chat_id=-42,
user_id=42,
can_manage_tags=True,
)
request = bot.get_request()
assert request.can_manage_tags is True
assert response == prepare_result.result

View file

@ -0,0 +1,14 @@
from aiogram.methods import SetChatMemberTag
from tests.mocked_bot import MockedBot
class TestSetChatMemberTag:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatMemberTag, ok=True, result=True)
response: bool = await bot.set_chat_member_tag(chat_id=-42, user_id=42, tag="test")
request = bot.get_request()
assert request.chat_id == -42
assert request.user_id == 42
assert request.tag == "test"
assert response == prepare_result.result

View file

@ -115,6 +115,14 @@ class TestChat:
method = chat.set_administrator_custom_title(user_id=1, custom_title="test")
assert method.chat_id == chat.id
def test_set_member_tag(self):
chat = Chat(id=-42, type="supergroup")
method = chat.set_member_tag(user_id=42, tag="test")
assert method.chat_id == chat.id
assert method.user_id == 42
assert method.tag == "test"
def test_set_permissions(self):
chat = Chat(id=-42, type="supergroup")

View file

@ -0,0 +1,84 @@
from datetime import datetime
from aiogram.types import (
ChatAdministratorRights,
ChatMemberAdministrator,
ChatMemberMember,
ChatMemberRestricted,
ChatPermissions,
User,
)
class TestChatMemberTagPermissions:
def test_chat_administrator_rights_can_manage_tags(self):
rights = ChatAdministratorRights(
is_anonymous=False,
can_manage_chat=True,
can_delete_messages=True,
can_manage_video_chats=True,
can_restrict_members=True,
can_promote_members=True,
can_change_info=True,
can_invite_users=True,
can_post_stories=True,
can_edit_stories=True,
can_delete_stories=True,
can_manage_tags=True,
)
assert rights.can_manage_tags is True
def test_chat_member_administrator_can_manage_tags(self):
admin = ChatMemberAdministrator(
user=User(id=42, is_bot=False, first_name="User"),
can_be_edited=True,
is_anonymous=False,
can_manage_chat=True,
can_delete_messages=True,
can_manage_video_chats=True,
can_restrict_members=True,
can_promote_members=True,
can_change_info=True,
can_invite_users=True,
can_post_stories=True,
can_edit_stories=True,
can_delete_stories=True,
can_manage_tags=True,
)
assert admin.can_manage_tags is True
def test_chat_permissions_can_edit_tag(self):
permissions = ChatPermissions(can_edit_tag=True)
assert permissions.can_edit_tag is True
def test_chat_member_member_tag(self):
member = ChatMemberMember(
user=User(id=42, is_bot=False, first_name="User"),
tag="premium",
)
assert member.tag == "premium"
def test_chat_member_restricted_can_edit_tag_and_tag(self):
restricted = ChatMemberRestricted(
user=User(id=42, is_bot=False, first_name="User"),
is_member=True,
can_send_messages=True,
can_send_audios=True,
can_send_documents=True,
can_send_photos=True,
can_send_videos=True,
can_send_video_notes=True,
can_send_voice_notes=True,
can_send_polls=True,
can_send_other_messages=True,
can_add_web_page_previews=True,
can_edit_tag=True,
can_change_info=True,
can_invite_users=True,
can_pin_messages=True,
can_manage_topics=True,
until_date=datetime.now(),
tag="premium",
)
assert restricted.can_edit_tag is True
assert restricted.tag == "premium"