From 50e608ac904c1c81dd2a30d0d71e8902680fbe7c Mon Sep 17 00:00:00 2001 From: Autuamn_End Date: Wed, 8 May 2024 13:47:12 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=20event=20?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E8=8E=B7=E5=8F=96=E9=94=99=E8=AF=AF=20#19=20?= =?UTF-8?q?(#26)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :bug: 修复 event 文本获取错误 #19 * :bug: 修改 `Message._construct()` 的正则 --- nonebot/adapters/discord/message.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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(