mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
Webhook integration in 3.0 (#737)
* Added base webhook implementation and example * Added example * Enable on_startup callback * Correctly handle response into webhook (silent call) * Fixed State filter
This commit is contained in:
parent
e0ab7d8bd3
commit
1c2c7fd88c
13 changed files with 865 additions and 246 deletions
|
|
@ -13,6 +13,7 @@ class MockedSession(BaseSession):
|
|||
super(MockedSession, self).__init__()
|
||||
self.responses: Deque[Response[TelegramType]] = deque()
|
||||
self.requests: Deque[Request] = deque()
|
||||
self.closed = True
|
||||
|
||||
def add_result(self, response: Response[TelegramType]) -> Response[TelegramType]:
|
||||
self.responses.append(response)
|
||||
|
|
@ -22,11 +23,12 @@ class MockedSession(BaseSession):
|
|||
return self.requests.pop()
|
||||
|
||||
async def close(self):
|
||||
pass
|
||||
self.closed = True
|
||||
|
||||
async def make_request(
|
||||
self, bot: Bot, method: TelegramMethod[TelegramType], timeout: Optional[int] = UNSET
|
||||
) -> TelegramType:
|
||||
self.closed = False
|
||||
self.requests.append(method.build_request(bot))
|
||||
response: Response[TelegramType] = self.responses.pop()
|
||||
self.check_response(
|
||||
|
|
@ -45,7 +47,9 @@ class MockedBot(Bot):
|
|||
session: MockedSession
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(MockedBot, self).__init__("42:TEST", session=MockedSession(), **kwargs)
|
||||
super(MockedBot, self).__init__(
|
||||
kwargs.pop("token", "42:TEST"), session=MockedSession(), **kwargs
|
||||
)
|
||||
self._me = User(
|
||||
id=self.id,
|
||||
is_bot=True,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue