Files
mai-bot/src/common/utils/utils_message.py
UnCLAS-Prommer b9f3c17e14 合并到远程
2026-02-13 13:41:58 +08:00

16 lines
521 B
Python

import msgpack
from src.common.data_models.message_component_model import MessageSequence
class MessageUtils:
@staticmethod
def from_db_record_msg_to_MaiSeq(raw_content: bytes) -> MessageSequence:
unpacked_data = msgpack.unpackb(raw_content)
return MessageSequence.from_dict(unpacked_data)
@staticmethod
async def from_MaiSeq_to_db_record_msg(msg: MessageSequence) -> bytes:
dict_representation = msg.to_dict()
return msgpack.packb(dict_representation) # type: ignore