From 0418c04557baf5967a4bdca5890c4fc88a65de89 Mon Sep 17 00:00:00 2001 From: Autuamn_End Date: Fri, 26 Apr 2024 19:45:16 +0800 Subject: [PATCH 1/4] =?UTF-8?q?:bug:=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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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..5495f5b 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( From 089a3511d255b91920d668c9b9dac1dd3fca89cd Mon Sep 17 00:00:00 2001 From: Autuamn_End Date: Fri, 26 Apr 2024 19:49:37 +0800 Subject: [PATCH 2/4] =?UTF-8?q?:bug:=20=E4=BF=AE=E6=94=B9=20`Message.=5Fco?= =?UTF-8?q?nstruct()`=20=E7=9A=84=E6=AD=A3=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot/adapters/discord/message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonebot/adapters/discord/message.py b/nonebot/adapters/discord/message.py index 5495f5b..8cea3c7 100644 --- a/nonebot/adapters/discord/message.py +++ b/nonebot/adapters/discord/message.py @@ -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()]: From 38cb838c090ca210acb1169ec212bbde94528ee6 Mon Sep 17 00:00:00 2001 From: Autuamn_End Date: Tue, 21 May 2024 12:10:39 +0800 Subject: [PATCH 3/4] =?UTF-8?q?:sparkles:=20=E4=B8=BA=20Webhook=20?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=20source=5Fguild=20=E5=92=8C=20source=5Fchan?= =?UTF-8?q?nel=20=E6=B7=BB=E5=8A=A0=E5=8D=95=E7=8B=AC=E7=9A=84=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit :bug: 修正 source_guild, source_channel 的类型标注 --- nonebot/adapters/discord/api/model.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/nonebot/adapters/discord/api/model.py b/nonebot/adapters/discord/api/model.py index ae51130..ce8c54e 100644 --- a/nonebot/adapters/discord/api/model.py +++ b/nonebot/adapters/discord/api/model.py @@ -2298,6 +2298,19 @@ class VoiceRegion(BaseModel): # Webhook # see https://discord.com/developers/docs/resources/webhook +class SourceGuild(BaseModel): + # partial guild object + id: Snowflake + name: str + icon: Optional[str] + + +class SourceChannel(BaseModel): + # partial channel object + id: Snowflake + name: str + + class Webhook(BaseModel): """Used to represent a webhook. @@ -2312,9 +2325,8 @@ class Webhook(BaseModel): avatar: Optional[str] = Field(...) token: Missing[str] = UNSET application_id: Optional[Snowflake] = Field(...) - source_guild: MissingOrNullable[Guild] = UNSET # partial guild object - # partial channel object - source_channel: MissingOrNullable[Channel] = UNSET + source_guild: Missing[SourceGuild] = UNSET + source_channel: Missing[SourceChannel] = UNSET url: Missing[str] = UNSET From 3beb05fd4309c10341d9bdf101bcd97b9e68acb5 Mon Sep 17 00:00:00 2001 From: Autuamn_End Date: Wed, 19 Jun 2024 18:25:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=90=9B=20=E4=B8=BA=20`icon`=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit thanks, shoucandanghehe Co-authored-by: 呵呵です <51957264+shoucandanghehe@users.noreply.github.com> --- nonebot/adapters/discord/api/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonebot/adapters/discord/api/model.py b/nonebot/adapters/discord/api/model.py index ce8c54e..6026e60 100644 --- a/nonebot/adapters/discord/api/model.py +++ b/nonebot/adapters/discord/api/model.py @@ -2302,7 +2302,7 @@ class SourceGuild(BaseModel): # partial guild object id: Snowflake name: str - icon: Optional[str] + icon: Optional[str] = None class SourceChannel(BaseModel):