Skip to content

Commit

Permalink
🐛 middleware(obv11): node.type
Browse files Browse the repository at this point in the history
  • Loading branch information
j1g5awi committed Aug 19, 2024
1 parent 102162f commit 96ae922
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions nonebot_plugin_all4one/middlewares/onebot_v11.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,19 @@ 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":
node_message = (
TypeAdapter(Message)
.validate_python(node["data"]["content"])
.exclude("forward")
)
if not node_message:
continue
nodes.append(
{
"user_id": node["data"]["user_id"],
"user_name": node["data"]["nickname"],
"message": await self.to_onebot_message(
node["data"]["content"]
message=node_message
),
}
)
Expand Down Expand Up @@ -226,7 +231,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"]
)
),
},
)
Expand Down

0 comments on commit 96ae922

Please sign in to comment.