diff --git a/nonebot/adapters/discord/message.py b/nonebot/adapters/discord/message.py index 3b49a1f..8cea3c7 100644 --- a/nonebot/adapters/discord/message.py +++ b/nonebot/adapters/discord/message.py @@ -36,7 +36,7 @@ SnowflakeType, TimeStampStyle, ) -from .utils import escape, unescape +from .utils import unescape class MessageSegment(BaseMessageSegment["Message"]): @@ -319,7 +319,7 @@ class TextSegment(MessageSegment): @override def __str__(self) -> str: - return escape(self.data["text"]) + return self.data["text"] class EmbedData(TypedDict): @@ -395,7 +395,7 @@ def __radd__( def _construct(msg: str) -> Iterable[MessageSegment]: text_begin = 0 for embed in re.finditer( - r"<(?P(@!|@&|@|#|/|:|a:|t:))?(?P.+?)>", + r"<(?P(@!|@&|@|#|/|:|a:|t:))(?P[^<]+?)>", msg, ): if content := msg[text_begin : embed.pos + embed.start()]: @@ -436,7 +436,7 @@ def from_guild_message(cls, message: MessageGet) -> "Message": if message.mention_everyone: msg.append(MessageSegment.mention_everyone()) if message.content: - msg.append(MessageSegment.text(message.content)) + msg.extend(Message(message.content)) if message.attachments: msg.extend( MessageSegment.attachment(