2024-12-01 12:31:11 +08:00
|
|
|
from typing import TypeVar, Union
|
2022-05-22 19:42:30 +08:00
|
|
|
|
2021-12-20 00:28:02 +08:00
|
|
|
from nonebot.adapters import Event, Message
|
2024-12-01 12:31:11 +08:00
|
|
|
from nonebot.params import EventMessage, EventPlainText, EventToMe, EventType
|
2021-12-20 00:28:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
async def event(e: Event) -> Event:
|
|
|
|
return e
|
|
|
|
|
|
|
|
|
2024-05-09 15:08:49 +08:00
|
|
|
async def postpone_event(e: "Event") -> Event:
|
|
|
|
return e
|
|
|
|
|
|
|
|
|
2022-05-22 19:42:30 +08:00
|
|
|
async def legacy_event(event):
|
|
|
|
return event
|
|
|
|
|
|
|
|
|
2024-02-06 12:48:23 +08:00
|
|
|
async def not_legacy_event(event: int): ...
|
2022-05-22 19:42:30 +08:00
|
|
|
|
|
|
|
|
2024-02-06 12:48:23 +08:00
|
|
|
class FooEvent(Event): ...
|
2022-03-20 19:40:43 +08:00
|
|
|
|
|
|
|
|
2022-05-22 19:42:30 +08:00
|
|
|
async def sub_event(e: FooEvent) -> FooEvent:
|
2022-03-20 19:40:43 +08:00
|
|
|
return e
|
|
|
|
|
|
|
|
|
2024-02-06 12:48:23 +08:00
|
|
|
class BarEvent(Event): ...
|
2022-05-22 19:42:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
async def union_event(e: Union[FooEvent, BarEvent]) -> Union[FooEvent, BarEvent]:
|
|
|
|
return e
|
|
|
|
|
|
|
|
|
2023-06-11 15:33:33 +08:00
|
|
|
E = TypeVar("E", bound=Event)
|
|
|
|
|
|
|
|
|
|
|
|
async def generic_event(e: E) -> E:
|
|
|
|
return e
|
|
|
|
|
|
|
|
|
|
|
|
CE = TypeVar("CE", Event, None)
|
|
|
|
|
|
|
|
|
|
|
|
async def generic_event_none(e: CE) -> CE:
|
|
|
|
return e
|
|
|
|
|
|
|
|
|
2024-02-06 12:48:23 +08:00
|
|
|
async def not_event(e: Union[int, Event]): ...
|
2022-05-22 19:42:30 +08:00
|
|
|
|
|
|
|
|
2021-12-20 00:28:02 +08:00
|
|
|
async def event_type(t: str = EventType()) -> str:
|
|
|
|
return t
|
|
|
|
|
|
|
|
|
|
|
|
async def event_message(msg: Message = EventMessage()) -> Message:
|
|
|
|
return msg
|
|
|
|
|
|
|
|
|
|
|
|
async def event_plain_text(text: str = EventPlainText()) -> str:
|
|
|
|
return text
|
|
|
|
|
|
|
|
|
|
|
|
async def event_to_me(to_me: bool = EventToMe()) -> bool:
|
|
|
|
return to_me
|