mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Add support for Telegram Bot API 9.1 (#1704)
* Add support for Telegram Bot API 9.1 features, including checklists, gifts, and new methods like `SendChecklist`, `EditMessageChecklist`, and `GetMyStarBalance`. Update changelog and improve `True` field descriptions. * Bump API Version * Refactor profile photo types to use `InputProfilePhotoType` enums instead of hardcoded literals * Refactor imports and clean up redundant code across methods, types, and webhook server classes
This commit is contained in:
parent
77ca49518e
commit
f060c08d16
117 changed files with 2565 additions and 466 deletions
35
tests/test_api/test_methods/test_edit_message_checklist.py
Normal file
35
tests/test_api/test_methods/test_edit_message_checklist.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import datetime
|
||||
|
||||
from aiogram.methods import EditMessageChecklist
|
||||
from aiogram.types import Chat, InputChecklist, InputChecklistTask, Message
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestEditMessageChecklist:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
EditMessageChecklist,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
||||
checklist = InputChecklist(
|
||||
title="Updated Checklist",
|
||||
tasks=[
|
||||
InputChecklistTask(id=1, text="Updated Task 1"),
|
||||
InputChecklistTask(id=2, text="Updated Task 2"),
|
||||
],
|
||||
)
|
||||
|
||||
response: Message = await bot.edit_message_checklist(
|
||||
business_connection_id="test_connection",
|
||||
chat_id=42,
|
||||
message_id=42,
|
||||
checklist=checklist,
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
18
tests/test_api/test_methods/test_get_my_star_balance.py
Normal file
18
tests/test_api/test_methods/test_get_my_star_balance.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
from aiogram.methods import GetMyStarBalance
|
||||
from aiogram.types import StarAmount
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestGetMyStarBalance:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetMyStarBalance,
|
||||
ok=True,
|
||||
result=StarAmount(
|
||||
amount=100,
|
||||
),
|
||||
)
|
||||
|
||||
response: StarAmount = await bot.get_my_star_balance()
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
34
tests/test_api/test_methods/test_send_checklist.py
Normal file
34
tests/test_api/test_methods/test_send_checklist.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import datetime
|
||||
|
||||
from aiogram.methods import SendChecklist
|
||||
from aiogram.types import Chat, InputChecklist, InputChecklistTask, Message
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSendChecklist:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendChecklist,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
||||
checklist = InputChecklist(
|
||||
title="Test Checklist",
|
||||
tasks=[
|
||||
InputChecklistTask(id=1, text="Task 1"),
|
||||
InputChecklistTask(id=2, text="Task 2"),
|
||||
],
|
||||
)
|
||||
|
||||
response: Message = await bot.send_checklist(
|
||||
business_connection_id="test_connection",
|
||||
chat_id=42,
|
||||
checklist=checklist,
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -16,6 +16,7 @@ from aiogram.methods import (
|
|||
PinChatMessage,
|
||||
SendAnimation,
|
||||
SendAudio,
|
||||
SendChecklist,
|
||||
SendContact,
|
||||
SendDice,
|
||||
SendDocument,
|
||||
|
|
@ -47,8 +48,13 @@ from aiogram.types import (
|
|||
ChatBackground,
|
||||
ChatBoostAdded,
|
||||
ChatShared,
|
||||
Checklist,
|
||||
ChecklistTask,
|
||||
ChecklistTasksAdded,
|
||||
ChecklistTasksDone,
|
||||
Contact,
|
||||
Dice,
|
||||
DirectMessagePriceChanged,
|
||||
Document,
|
||||
EncryptedCredentials,
|
||||
ForumTopicClosed,
|
||||
|
|
@ -692,6 +698,58 @@ TEST_MESSAGE_UNIQUE_GIFT = Message(
|
|||
origin="upgrade",
|
||||
),
|
||||
)
|
||||
TEST_MESSAGE_CHECKLIST = Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
checklist=Checklist(
|
||||
title="Test Checklist",
|
||||
tasks=[
|
||||
ChecklistTask(
|
||||
id=1,
|
||||
text="Task 1",
|
||||
),
|
||||
ChecklistTask(
|
||||
id=2,
|
||||
text="Task 2",
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
TEST_MESSAGE_CHECKLIST_TASKS_DONE = Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
checklist_tasks_done=ChecklistTasksDone(
|
||||
marked_as_done_task_ids=[1, 2],
|
||||
),
|
||||
)
|
||||
TEST_MESSAGE_CHECKLIST_TASKS_ADDED = Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
checklist_tasks_added=ChecklistTasksAdded(
|
||||
tasks=[
|
||||
ChecklistTask(
|
||||
id=3,
|
||||
text="New Task",
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
TEST_MESSAGE_DIRECT_MESSAGE_PRICE_CHANGED = Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
direct_message_price_changed=DirectMessagePriceChanged(
|
||||
are_direct_messages_enabled=True,
|
||||
direct_message_star_count=50,
|
||||
),
|
||||
)
|
||||
TEST_MESSAGE_PAID_MESSAGE_PRICE_CHANGED = Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
|
|
@ -713,6 +771,7 @@ MESSAGES_AND_CONTENT_TYPES = [
|
|||
[TEST_MESSAGE_VIDEO, ContentType.VIDEO],
|
||||
[TEST_MESSAGE_VIDEO_NOTE, ContentType.VIDEO_NOTE],
|
||||
[TEST_MESSAGE_VOICE, ContentType.VOICE],
|
||||
[TEST_MESSAGE_CHECKLIST, ContentType.CHECKLIST],
|
||||
[TEST_MESSAGE_CONTACT, ContentType.CONTACT],
|
||||
[TEST_MESSAGE_VENUE, ContentType.VENUE],
|
||||
[TEST_MESSAGE_LOCATION, ContentType.LOCATION],
|
||||
|
|
@ -764,6 +823,9 @@ MESSAGES_AND_CONTENT_TYPES = [
|
|||
[TEST_MESSAGE_WRITE_ACCESS_ALLOWED, ContentType.WRITE_ACCESS_ALLOWED],
|
||||
[TEST_MESSAGE_BOOST_ADDED, ContentType.BOOST_ADDED],
|
||||
[TEST_CHAT_BACKGROUND_SET, ContentType.CHAT_BACKGROUND_SET],
|
||||
[TEST_MESSAGE_CHECKLIST_TASKS_DONE, ContentType.CHECKLIST_TASKS_DONE],
|
||||
[TEST_MESSAGE_CHECKLIST_TASKS_ADDED, ContentType.CHECKLIST_TASKS_ADDED],
|
||||
[TEST_MESSAGE_DIRECT_MESSAGE_PRICE_CHANGED, ContentType.DIRECT_MESSAGE_PRICE_CHANGED],
|
||||
[TEST_REFUND_PAYMENT, ContentType.REFUNDED_PAYMENT],
|
||||
[TEST_MESSAGE_GIFT, ContentType.GIFT],
|
||||
[TEST_MESSAGE_UNIQUE_GIFT, ContentType.UNIQUE_GIFT],
|
||||
|
|
@ -783,6 +845,7 @@ MESSAGES_AND_COPY_METHODS = [
|
|||
[TEST_MESSAGE_VIDEO, SendVideo],
|
||||
[TEST_MESSAGE_VIDEO_NOTE, SendVideoNote],
|
||||
[TEST_MESSAGE_VOICE, SendVoice],
|
||||
[TEST_MESSAGE_CHECKLIST, None],
|
||||
[TEST_MESSAGE_CONTACT, SendContact],
|
||||
[TEST_MESSAGE_VENUE, SendVenue],
|
||||
[TEST_MESSAGE_LOCATION, SendLocation],
|
||||
|
|
@ -828,6 +891,9 @@ MESSAGES_AND_COPY_METHODS = [
|
|||
[TEST_MESSAGE_GIVEAWAY_WINNERS, None],
|
||||
[TEST_MESSAGE_BOOST_ADDED, None],
|
||||
[TEST_CHAT_BACKGROUND_SET, None],
|
||||
[TEST_MESSAGE_CHECKLIST_TASKS_DONE, None],
|
||||
[TEST_MESSAGE_CHECKLIST_TASKS_ADDED, None],
|
||||
[TEST_MESSAGE_DIRECT_MESSAGE_PRICE_CHANGED, None],
|
||||
[TEST_REFUND_PAYMENT, None],
|
||||
[TEST_MESSAGE_GIFT, None],
|
||||
[TEST_MESSAGE_UNIQUE_GIFT, None],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue