nonebot2/tests/test_plugins/test_permission.py

19 lines
648 B
Python
Raw Normal View History

2020-09-10 18:31:53 +08:00
from nonebot.rule import to_me
2020-12-07 00:06:09 +08:00
from nonebot.typing import State
2020-09-10 18:31:53 +08:00
from nonebot.plugin import on_startswith
from nonebot.permission import GROUP_ADMIN
2020-12-07 00:06:09 +08:00
from nonebot.adapters.ding import Bot as DingBot, Event as DingEvent
from nonebot.adapters.cqhttp import Bot as CQHTTPBot, Event as CQHTTPEvent
2020-09-10 18:31:53 +08:00
test_command = on_startswith("hello", to_me(), permission=GROUP_ADMIN)
@test_command.handle()
2020-12-07 00:06:09 +08:00
async def test_handler(bot: CQHTTPBot, event: CQHTTPEvent, state: State):
2020-12-03 18:47:58 +08:00
await test_command.finish("cqhttp hello")
@test_command.handle()
2020-12-07 00:06:09 +08:00
async def test_handler(bot: DingBot, event: DingEvent, state: State):
2020-12-03 18:47:58 +08:00
await test_command.finish("ding hello")