nonebot2/tests/test_plugins/test_matcher.py

23 lines
613 B
Python
Raw Normal View History

2020-06-30 10:13:58 +08:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from nonebot.rule import Rule
2020-08-13 15:23:04 +08:00
from nonebot.typing import Event
2020-06-30 10:13:58 +08:00
from nonebot.plugin import on_message
2020-08-13 15:23:04 +08:00
from nonebot.adapters.cqhttp import Bot, Message
2020-07-18 18:18:43 +08:00
2020-08-14 17:41:24 +08:00
test_matcher = on_message(state={"default": 1})
2020-06-30 10:13:58 +08:00
@test_matcher.handle()
2020-08-13 15:23:04 +08:00
async def test_handler(bot: Bot, event: Event, state: dict):
2020-07-11 17:32:03 +08:00
print("Test Matcher Received:", event)
print("Current State:", state)
2020-08-13 15:23:04 +08:00
state["event"] = event
2020-07-11 17:32:03 +08:00
@test_matcher.receive()
2020-08-13 15:23:04 +08:00
async def test_receive(bot: Bot, event: Event, state: dict):
2020-07-11 17:32:03 +08:00
print("Test Matcher Received next time:", event)
print("Current State:", state)