add command alias/group test

This commit is contained in:
yanyongyu
2020-09-27 23:52:03 +08:00
parent 4e4d494ffd
commit 2921ba0120
4 changed files with 22 additions and 27 deletions

View File

@ -0,0 +1,6 @@
from nonebot.rule import to_me
from nonebot import CommandGroup
test = CommandGroup("test", rule=to_me())
from . import commands

View File

@ -0,0 +1,11 @@
from nonebot.typing import Bot, Event
from nonebot.permission import GROUP_OWNER
from . import test
test_1 = test.command("1", aliases={"test"}, permission=GROUP_OWNER)
@test_1.handle()
async def test1(bot: Bot, event: Event, state: dict):
await test_1.finish(event.raw_message)

View File

@ -1,22 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from nonebot.rule import to_me
from nonebot.typing import Event
from nonebot.plugin import on_message
from nonebot.adapters.cqhttp import Bot
test_message = on_message(to_me(), state={"default": 1})
@test_message.handle()
async def test_handler(bot: Bot, event: Event, state: dict):
print("[*] Test Matcher Received:", event)
state["event"] = event
await bot.send(message="Received", event=event)
@test_message.receive()
async def test_receive(bot: Bot, event: Event, state: dict):
print("[*] Test Matcher Received next time:", event)
print("[*] Current State:", state)