nonebot2/tests/test_plugins/test_metaevent.py

18 lines
377 B
Python
Raw Normal View History

2020-07-25 04:28:30 +00:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from nonebot.plugin import on_metaevent
2020-08-14 09:41:24 +00:00
from nonebot.typing import Bot, Event
2020-07-25 04:28:30 +00:00
2020-08-14 09:41:24 +00:00
def heartbeat(bot: Bot, event: Event) -> 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
@test_matcher.handle()
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")