From dc5aa3d4bf17bbd8b12a6eeb20bbae2d889db2db Mon Sep 17 00:00:00 2001 From: StarHeartHunt Date: Tue, 6 Jul 2021 22:01:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20remove=20rich=5Ftext=20parser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nonebot/adapters/feishu/event.py | 6 ++--- .../nonebot/adapters/feishu/message.py | 22 +------------------ 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/event.py b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/event.py index 9f1edd9a..8cf0422a 100644 --- a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/event.py +++ b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/event.py @@ -138,12 +138,10 @@ class MessageEvent(Event): @overrides(Event) def get_event_description(self) -> str: - #TODO:换成GroupId return ( - f"Message[{super().get_type()}]" - f" {self.event.message.message_id} from {self.get_user_id()}" + f"{self.event.message.message_id} from {self.get_user_id()}" f"@[{self.event.message.chat_type}:{self.event.message.chat_id}]" - f" {str(self.get_message()) and MessageSerializer(self.get_message()).serialize()}") + f" {MessageSerializer(self.get_message()).serialize()[1]}") @overrides(Event) def get_message(self) -> Message: diff --git a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py index 624baefd..236d01ea 100644 --- a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py +++ b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py @@ -199,24 +199,4 @@ class MessageDeserializer: data: Dict[str, Any] def deserialize(self) -> Message: - if self.type == "post": - return Message(self._parse_rich_text(self.data)) - else: - return Message(MessageSegment(self.type, self.data)) - - def _parse_rich_text(self, message_data: Dict[str, - Any]) -> List[MessageSegment]: - - def _iter_message( - message_data: Dict[str, - Any]) -> Iterable[Tuple[str, Dict[str, Any]]]: - content: dict = message_data.get("content", {}) - if content: - for element in list(itertools.chain(*content)): - tag = element.get("tag") - yield tag, element - - return [ - MessageSegment(type_, data) - for type_, data in _iter_message(message_data) - ] + return Message(MessageSegment(self.type, self.data))