Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 修复 event 文本获取错误 #19 #26

Merged
merged 2 commits into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions nonebot/adapters/discord/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
SnowflakeType,
TimeStampStyle,
)
from .utils import escape, unescape
from .utils import unescape


class MessageSegment(BaseMessageSegment["Message"]):
Expand Down Expand Up @@ -319,7 +319,7 @@ class TextSegment(MessageSegment):

@override
def __str__(self) -> str:
return escape(self.data["text"])
return self.data["text"]


class EmbedData(TypedDict):
Expand Down Expand Up @@ -395,7 +395,7 @@ def __radd__(
def _construct(msg: str) -> Iterable[MessageSegment]:
text_begin = 0
for embed in re.finditer(
r"<(?P<type>(@!|@&|@|#|/|:|a:|t:))?(?P<param>.+?)>",
r"<(?P<type>(@!|@&|@|#|/|:|a:|t:))(?P<param>[^<]+?)>",
msg,
):
if content := msg[text_begin : embed.pos + embed.start()]:
Expand Down Expand Up @@ -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(
Expand Down
Loading