mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Add support for purchased paid media events
Enhanced the router to include `purchased_paid_media` handling. Added corresponding test cases to verify the new functionality and updated middleware to return the appropriate `EventContext`.
This commit is contained in:
parent
c79da13d8e
commit
1cb36adf21
3 changed files with 18 additions and 0 deletions
|
|
@ -175,4 +175,8 @@ class UserContextMiddleware(BaseMiddleware):
|
|||
),
|
||||
business_connection_id=event.edited_business_message.business_connection_id,
|
||||
)
|
||||
if event.purchased_paid_media:
|
||||
return EventContext(
|
||||
user=event.purchased_paid_media.from_user,
|
||||
)
|
||||
return EventContext()
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ class Router:
|
|||
"business_connection": self.business_connection,
|
||||
"edited_business_message": self.edited_business_message,
|
||||
"business_message": self.business_message,
|
||||
"purchased_paid_media": self.purchased_paid_media,
|
||||
"error": self.errors,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ from aiogram.types import (
|
|||
ShippingQuery,
|
||||
Update,
|
||||
User,
|
||||
PaidMediaPurchased,
|
||||
)
|
||||
from aiogram.types.error_event import ErrorEvent
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
|
@ -586,6 +587,18 @@ class TestDispatcher:
|
|||
True,
|
||||
True,
|
||||
),
|
||||
pytest.param(
|
||||
"purchased_paid_media",
|
||||
Update(
|
||||
update_id=42,
|
||||
purchased_paid_media=PaidMediaPurchased(
|
||||
paid_media_payload="payload",
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
),
|
||||
),
|
||||
False,
|
||||
True,
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_listen_update(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue