MahjongRepository / mahjong_soul_api

Python wrapper for the Mahjong Soul (Majsoul) Protobuf objects. It allows to use their API.
72 stars 10 forks source link

How to decode byte data? #25

Closed iceshoesss closed 5 months ago

iceshoesss commented 8 months ago
    req = pb.ReqJoinCustomizedContestChatRoom()
    req.unique_id = unique_id
    res = await lobby.join_customized_contest_chat_room(req)
    print(res.chat_history[2])

I got a byte data like this

b'\n .lq.NotifyCustomContestSystemMsg\x12\xa2\x01\x08\x9a\x88\x01\x10\x01\x1a+240312-867fda4f-3b41-45ac-93ba-3e2ddf72b8c4"m\n\x1c\x08\xb1\x94\x9b\x05\x12\x15\xe6\x95\xa3\xe5\x8f\x91\xe5\xa6\x96\xe6\xb0\x94\xe7\x9a\x84\xe6\x95\xa3\xe4\xbb\x99\n\x1a\x08\xdd\xdd\x9b\x05\x12\x13\xe5\x85\xb3\xe6\xb3\xa8\xe6\xb0\xb8\xe9\x9b\x8f\xe5\xa1\x94\xe8\x8f\xb21\n\x13\x08\xf6\xaf\xb7\x08\x12\x0c\xe9\x82\x91\xe7\xbb\x9f\xe5\xa4\xa9\xe4\xb8\x8b\n\x1c\x08\x96\xeb\xc3\x0b\x12\x15\xe3\x80\xa3\xe3\x80\xa1\xe9\xa5\x85\xe3\x80\xa5\xe9\xa0\xad\xe3\x80\xa2\xe5\xb7\x9c'

How to decode this data to format that human can understand?

unStatiK commented 8 months ago

@iceshoesss in mahjongsoul protobuf protocol bytes data ALWAYS means "protobuf in protobuf". You should use Wrapper for extract inner protobuf data. See example for that https://github.com/MahjongRepository/mahjong_soul_api/blob/master/example.py#L134-L138