nonebot2/tests/test_plugins/test_metaevent.py

16 lines
385 B
Python
Raw Normal View History

2020-12-07 00:06:09 +08:00
from nonebot.typing import State
from nonebot.adapters import Bot, Event
2020-08-24 17:59:36 +08:00
from nonebot.plugin import on_metaevent
2020-07-25 12:28:30 +08:00
2020-12-07 00:06:09 +08:00
async def heartbeat(bot: Bot, event: Event, state: State) -> bool:
2020-07-25 12:28:30 +08:00
return event.detail_type == "heartbeat"
2020-08-14 17:41:24 +08:00
test_matcher = on_metaevent(heartbeat)
2020-07-25 12:28:30 +08:00
2020-08-23 10:45:26 +08:00
@test_matcher.receive()
2020-08-14 17:41:24 +08:00
async def handle_heartbeat(bot: Bot, event: Event, state: dict):
2020-07-25 12:28:30 +08:00
print("[i] Heartbeat")