mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 00:55:07 +08:00
✅ add specified test for mirai adapter
This commit is contained in:
parent
c0fa137fed
commit
da1218221c
@ -11,3 +11,7 @@ COMMAND_SEP=["/", "."]
|
||||
|
||||
CUSTOM_CONFIG1=config in env
|
||||
CUSTOM_CONFIG3=
|
||||
|
||||
MIRAI_AUTH_KEY=12345678
|
||||
MIRAI_HOST=127.0.0.1
|
||||
MIRAI_PORT=8080
|
@ -6,6 +6,7 @@ sys.path.insert(0, os.path.abspath(".."))
|
||||
import nonebot
|
||||
from nonebot.adapters.cqhttp import Bot
|
||||
from nonebot.adapters.ding import Bot as DingBot
|
||||
from nonebot.adapters.mirai import Bot as MiraiBot
|
||||
from nonebot.log import logger, default_format
|
||||
|
||||
# test custom log
|
||||
@ -20,6 +21,7 @@ app = nonebot.get_asgi()
|
||||
driver = nonebot.get_driver()
|
||||
driver.register_adapter("cqhttp", Bot)
|
||||
driver.register_adapter("ding", DingBot)
|
||||
driver.register_adapter("mirai", MiraiBot)
|
||||
|
||||
# load builtin plugin
|
||||
nonebot.load_builtin_plugins()
|
||||
|
13
tests/test_plugins/test_mirai.py
Normal file
13
tests/test_plugins/test_mirai.py
Normal file
@ -0,0 +1,13 @@
|
||||
from nonebot.plugin import on_message
|
||||
from nonebot.adapters.mirai import Bot, MessageEvent
|
||||
|
||||
message_test = on_message()
|
||||
|
||||
|
||||
@message_test.handle()
|
||||
async def _message(bot: Bot, event: MessageEvent):
|
||||
text = event.get_plaintext()
|
||||
if not text:
|
||||
return
|
||||
reversed_text = ''.join(reversed(text))
|
||||
await bot.send(event, reversed_text, at_sender=True)
|
Loading…
Reference in New Issue
Block a user