From 668becda85d18e0a5dc69f8fb11e0c294e96a1c6 Mon Sep 17 00:00:00 2001 From: jigsaw Date: Mon, 19 Aug 2024 13:50:25 +0800 Subject: [PATCH] :bug: middleware(obv11): node.type --- nonebot_plugin_all4one/middlewares/onebot_v11.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nonebot_plugin_all4one/middlewares/onebot_v11.py b/nonebot_plugin_all4one/middlewares/onebot_v11.py index 6d46f97..3dfcd94 100644 --- a/nonebot_plugin_all4one/middlewares/onebot_v11.py +++ b/nonebot_plugin_all4one/middlewares/onebot_v11.py @@ -167,14 +167,16 @@ async def to_onebot_message(self, message: Message) -> OneBotMessage: resp = await self.bot.get_forward_msg(id=segment.data["id"]) nodes = [] for node in resp["message"]: - if node.type == "forward": + if node["type"] == "forward": continue nodes.append( { "user_id": node["data"]["user_id"], "user_name": node["data"]["nickname"], "message": await self.to_onebot_message( - node["data"]["content"] + message=TypeAdapter(Message).validate_python( + node["content"] + ) ), } ) @@ -226,7 +228,9 @@ async def from_onebot_message(self, message: OneBotMessage) -> Message: "name": node["user_name"], "uin": node["user_id"], "content": await self.from_onebot_message( - node["message"] + message=TypeAdapter(OneBotMessage).validate_python( + node["message"] + ) ), }, )