add specified test for mirai adapter

This commit is contained in:
Mix 2021-02-01 16:37:42 +08:00
parent c0fa137fed
commit da1218221c
3 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -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()

View 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)