2023-06-11 15:33:33 +08:00
|
|
|
from typing import Union, TypeVar
|
|
|
|
|
2021-12-20 00:28:02 +08:00
|
|
|
from nonebot.adapters import Event
|
|
|
|
from nonebot.matcher import Matcher
|
|
|
|
from nonebot.params import Received, LastReceived
|
|
|
|
|
|
|
|
|
|
|
|
async def matcher(m: Matcher) -> Matcher:
|
|
|
|
return m
|
|
|
|
|
|
|
|
|
2023-06-11 15:33:33 +08:00
|
|
|
async def legacy_matcher(matcher):
|
|
|
|
return matcher
|
|
|
|
|
|
|
|
|
2024-02-06 12:48:23 +08:00
|
|
|
async def not_legacy_matcher(matcher: int): ...
|
2023-06-11 15:33:33 +08:00
|
|
|
|
|
|
|
|
2024-02-06 12:48:23 +08:00
|
|
|
class FooMatcher(Matcher): ...
|
2023-06-11 15:33:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
async def sub_matcher(m: FooMatcher) -> FooMatcher:
|
|
|
|
return m
|
|
|
|
|
|
|
|
|
2024-02-06 12:48:23 +08:00
|
|
|
class BarMatcher(Matcher): ...
|
2023-06-11 15:33:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
async def union_matcher(
|
|
|
|
m: Union[FooMatcher, BarMatcher]
|
|
|
|
) -> Union[FooMatcher, BarMatcher]:
|
|
|
|
return m
|
|
|
|
|
|
|
|
|
|
|
|
M = TypeVar("M", bound=Matcher)
|
|
|
|
|
|
|
|
|
|
|
|
async def generic_matcher(m: M) -> M:
|
|
|
|
return m
|
|
|
|
|
|
|
|
|
|
|
|
CM = TypeVar("CM", Matcher, None)
|
|
|
|
|
|
|
|
|
|
|
|
async def generic_matcher_none(m: CM) -> CM:
|
|
|
|
return m
|
|
|
|
|
|
|
|
|
2024-02-06 12:48:23 +08:00
|
|
|
async def not_matcher(m: Union[int, Matcher]): ...
|
2023-06-11 15:33:33 +08:00
|
|
|
|
|
|
|
|
2021-12-20 00:28:02 +08:00
|
|
|
async def receive(e: Event = Received("test")) -> Event:
|
|
|
|
return e
|
|
|
|
|
|
|
|
|
|
|
|
async def last_receive(e: Event = LastReceived()) -> Event:
|
|
|
|
return e
|