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
|
2020-12-06 02:30:19 +08:00
|
|
|
from nonebot.typing import State
|
2020-08-29 21:59:36 +08:00
|
|
|
from nonebot.plugin import on_command
|
2020-10-04 18:10:01 +08:00
|
|
|
from nonebot.permission import SUPERUSER
|
2020-12-07 00:06:09 +08:00
|
|
|
from nonebot.adapters 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-12-06 02:30:19 +08:00
|
|
|
async def say_unescape(bot: Bot, event: Event, state: State):
|
2020-12-10 02:13:25 +08:00
|
|
|
Message = event.get_message().__class__
|
2020-10-04 18:10:01 +08:00
|
|
|
|
|
|
|
def _unescape(message: Message, segment: MessageSegment):
|
2020-12-10 02:13:25 +08:00
|
|
|
if segment.is_text():
|
2020-12-02 20:51:35 +08:00
|
|
|
return message.append(str(segment))
|
2020-10-04 18:10:01 +08:00
|
|
|
return message.append(segment)
|
|
|
|
|
2020-12-10 02:13:25 +08:00
|
|
|
message = reduce(_unescape, event.get_message(), Message()) # type: ignore
|
2020-10-04 18:10:01 +08:00
|
|
|
await bot.send(message=message, event=event)
|
|
|
|
|
|
|
|
|
|
|
|
echo = on_command("echo", to_me())
|
|
|
|
|
|
|
|
|
|
|
|
@echo.handle()
|
2020-12-06 02:30:19 +08:00
|
|
|
async def echo_escape(bot: Bot, event: Event, state: State):
|
2020-12-10 02:13:25 +08:00
|
|
|
await bot.send(message=event.get_message(), event=event)
|