2022-05-22 19:42:30 +08:00
|
|
|
from typing import Union
|
|
|
|
|
2021-12-20 00:28:02 +08:00
|
|
|
from nonebot.adapters import Event, Message
|
|
|
|
from nonebot.params import EventToMe, EventType, EventMessage, EventPlainText
|
|
|
|
|
|
|
|
|
|
|
|
async def event(e: Event) -> Event:
|
|
|
|
return e
|
|
|
|
|
|
|
|
|
2022-05-22 19:42:30 +08:00
|
|
|
async def legacy_event(event):
|
|
|
|
return event
|
|
|
|
|
|
|
|
|
|
|
|
async def not_legacy_event(event: int):
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2022-05-22 19:42:30 +08:00
|
|
|
class BarEvent(Event):
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
async def union_event(e: Union[FooEvent, BarEvent]) -> Union[FooEvent, BarEvent]:
|
|
|
|
return e
|
|
|
|
|
|
|
|
|
|
|
|
async def not_event(e: Union[int, Event]):
|
|
|
|
...
|
|
|
|
|
|
|
|
|
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
|