From fe43c8d69a2829666a08dd540c78ebc8450e3e15 Mon Sep 17 00:00:00 2001 From: StarHeartHunt Date: Wed, 7 Jul 2021 22:36:08 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A9=20should=20implement=20rich=20text?= =?UTF-8?q?=20parser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nonebot/adapters/feishu/message.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py index 0d059f42..3a1201d6 100644 --- a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py +++ b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py @@ -1,4 +1,5 @@ import json +import itertools from dataclasses import dataclass from typing import Any, Dict, Tuple, Type, Union, Mapping, Iterable @@ -18,8 +19,17 @@ class MessageSegment(BaseMessageSegment["Message"]): return Message def __str__(self) -> str: - if self.type == "text" or self.type == "hongbao": + if self.type == "post": + return "".join( + str(MessageSegment(seg["tag"], seg)) + for seg in itertools.chain(*self.data["content"])) + + elif self.type == "text" or self.type == "hongbao": return str(self.data["text"]) + + elif self.type == "img" or self.type == "image": + return "[图片]" + return "" @overrides(BaseMessageSegment)