🔥 remove rich_text parser

This commit is contained in:
StarHeartHunt 2021-07-06 22:01:02 +08:00
parent b9befc8350
commit dc5aa3d4bf
2 changed files with 3 additions and 25 deletions

View File

@ -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:

View File

@ -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))