nonebot2/tests/test_plugins/test_metaevent.py

18 lines
397 B
Python
Raw Normal View History

2020-07-25 12:28:30 +08:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from nonebot.plugin import on_metaevent
2020-08-14 17:41:24 +08:00
from nonebot.typing import Bot, Event
2020-07-25 12:28:30 +08:00
2020-08-20 15:07:05 +08:00
async def heartbeat(bot: Bot, event: Event, state: dict) -> 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")