2020-10-04 18:10:01 +08:00
|
|
|
from functools import reduce
|
|
|
|
|
2020-08-29 21:59:36 +08:00
|
|
|
from nonebot.rule import to_me
|
|
|
|
from nonebot.plugin import on_command
|
2020-10-04 18:10:01 +08:00
|
|
|
from nonebot.permission import SUPERUSER
|
|
|
|
from nonebot.typing import Bot, Event, MessageSegment
|
2020-08-29 21:59:36 +08:00
|
|
|
|
2020-10-04 18:10:01 +08:00
|
|
|
say = on_command("say", to_me(), permission=SUPERUSER)
|
2020-08-29 21:59:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
@say.handle()
|
2020-10-04 18:10:01 +08:00
|
|
|
async def say_unescape(bot: Bot, event: Event, state: dict):
|
|
|
|
Message = event.message.__class__
|
|
|
|
|
|
|
|
def _unescape(message: Message, segment: MessageSegment):
|
|
|
|
if segment.type == "text":
|
|
|
|
return message.append(segment.data["text"])
|
|
|
|
return message.append(segment)
|
|
|
|
|
|
|
|
message = reduce(_unescape, event.message, Message()) # type: ignore
|
|
|
|
await bot.send(message=message, event=event)
|
|
|
|
|
|
|
|
|
|
|
|
echo = on_command("echo", to_me())
|
|
|
|
|
|
|
|
|
|
|
|
@echo.handle()
|
|
|
|
async def echo_escape(bot: Bot, event: Event, state: dict):
|
2020-11-07 12:36:47 +08:00
|
|
|
# Message = event.message.__class__
|
|
|
|
# MessageSegment = event.message[0].__class__
|
2020-10-04 18:10:01 +08:00
|
|
|
|
2020-11-07 12:36:47 +08:00
|
|
|
# message = Message().append( # type: ignore
|
|
|
|
# MessageSegment.text(str(event.message)))
|
|
|
|
await bot.send(message=event.message, event=event)
|