mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-16 19:11:00 +00:00
✅ test matchergroup
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
from nonebot.rule import to_me
|
||||
from nonebot import CommandGroup
|
||||
from nonebot import CommandGroup, MatcherGroup
|
||||
|
||||
test = CommandGroup("test", rule=to_me())
|
||||
cmd = CommandGroup("test", rule=to_me())
|
||||
match = MatcherGroup(priority=2)
|
||||
|
||||
from . import commands
|
||||
from . import commands, matches
|
||||
|
@ -1,9 +1,9 @@
|
||||
from nonebot.typing import Bot, Event
|
||||
from nonebot.permission import GROUP_OWNER
|
||||
|
||||
from . import test
|
||||
from . import cmd
|
||||
|
||||
test_1 = test.command("1", aliases={"test"}, permission=GROUP_OWNER)
|
||||
test_1 = cmd.command("1", aliases={"test"}, permission=GROUP_OWNER)
|
||||
|
||||
|
||||
@test_1.handle()
|
||||
|
15
tests/test_plugins/test_group/matches.py
Normal file
15
tests/test_plugins/test_group/matches.py
Normal file
@ -0,0 +1,15 @@
|
||||
from nonebot.typing import Bot, Event
|
||||
|
||||
from . import match
|
||||
|
||||
|
||||
async def heartbeat(bot: Bot, event: Event, state: dict) -> bool:
|
||||
return event.detail_type == "heartbeat"
|
||||
|
||||
|
||||
test = match.on_metaevent(rule=heartbeat)
|
||||
|
||||
|
||||
@test.receive()
|
||||
async def handle_heartbeat(bot: Bot, event: Event, state: dict):
|
||||
print("[i] Heartbeat")
|
Reference in New Issue
Block a user