nonebot2/tests/test_plugins/test_metaevent.py

18 lines
377 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-14 17:41:24 +08:00
def heartbeat(bot: Bot, event: Event) -> 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
@test_matcher.handle()
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")