nonebot2/tests/test_plugins/test_metaevent.py

18 lines
397 B
Python
Raw Normal View History

2020-07-25 04:28:30 +00:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
2020-08-14 09:41:24 +00:00
from nonebot.typing import Bot, Event
2020-08-24 09:59:36 +00:00
from nonebot.plugin import on_metaevent
2020-07-25 04:28:30 +00:00
2020-08-20 07:07:05 +00:00
async def heartbeat(bot: Bot, event: Event, state: dict) -> bool:
2020-07-25 04:28:30 +00:00
return event.detail_type == "heartbeat"
2020-08-14 09:41:24 +00:00
test_matcher = on_metaevent(heartbeat)
2020-07-25 04:28:30 +00:00
2020-08-23 02:45:26 +00:00
@test_matcher.receive()
2020-08-14 09:41:24 +00:00
async def handle_heartbeat(bot: Bot, event: Event, state: dict):
2020-07-25 04:28:30 +00:00
print("[i] Heartbeat")