Skip to content

Commit

Permalink
🐛 automatically merge message with at_sender=True
Browse files Browse the repository at this point in the history
  • Loading branch information
StarHeartHunt committed Oct 22, 2023
1 parent ebe14ef commit befefa3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion nonebot/adapters/feishu/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,19 @@ def serialize(self) -> Tuple[str, str]:
combined = {"zh_cn": {"title": "", "content": [[]]}}
if len(self) >= 2:
for seg in self:
combined["zh_cn"]["content"][0].append({"tag": seg.type, **seg.data})
if seg.type != "post":
combined["zh_cn"]["content"][-1].append(
{"tag": seg.type, **seg.data}
)
else:
zh_cn_data = seg.data.pop("zh_cn", None)
if zh_cn_data:
combined["zh_cn"]["title"] = zh_cn_data["title"]
combined["zh_cn"]["content"] = [
*combined["zh_cn"]["content"],
*zh_cn_data["content"],
]
combined.update(seg.data)

return "post", json.dumps(combined, ensure_ascii=False)
else:
Expand Down

0 comments on commit befefa3

Please sign in to comment.