mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-28 08:12:14 +08:00
🔥 remove rich_text parser
This commit is contained in:
parent
b9befc8350
commit
dc5aa3d4bf
@ -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.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:
|
||||
|
@ -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)
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user