mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
* Bump version * Added more comments * Cover registering global filters * Reformat code * Add more tests * Rework event propagation to routers mechanism. Fixed compatibility with Python 3.10 syntax (match keyword) * Fixed tests * Fixed coverage Co-authored-by: evgfilim1 <evgfilim1@yandex.ru>
30 lines
728 B
Python
30 lines
728 B
Python
from __future__ import annotations
|
|
|
|
from typing import Any, Awaitable, Callable, Dict, NoReturn, Optional, Union
|
|
from unittest.mock import sentinel
|
|
|
|
from ...types import TelegramObject
|
|
from ..middlewares.base import BaseMiddleware
|
|
|
|
NextMiddlewareType = Callable[[TelegramObject, Dict[str, Any]], Awaitable[Any]]
|
|
MiddlewareType = Union[
|
|
BaseMiddleware, Callable[[NextMiddlewareType, TelegramObject, Dict[str, Any]], Awaitable[Any]]
|
|
]
|
|
|
|
UNHANDLED = sentinel.UNHANDLED
|
|
REJECTED = sentinel.REJECTED
|
|
|
|
|
|
class SkipHandler(Exception):
|
|
pass
|
|
|
|
|
|
class CancelHandler(Exception):
|
|
pass
|
|
|
|
|
|
def skip(message: Optional[str] = None) -> NoReturn:
|
|
"""
|
|
Raise an SkipHandler
|
|
"""
|
|
raise SkipHandler(message or "Event skipped")
|