github.com/Mrs4s/MiraiGo@v0.0.0-20240226124653-54bdd873e3fe/message/marketface.go (about) 1 package message 2 3 import ( 4 "fmt" 5 6 "github.com/Mrs4s/MiraiGo/client/pb/msg" 7 "github.com/Mrs4s/MiraiGo/internal/proto" 8 "github.com/Mrs4s/MiraiGo/utils" 9 ) 10 11 type MarketFaceElement struct { 12 Name string 13 FaceId []byte // decoded = mediaType == 2 ? string(FaceId) : hex.EncodeToString(FaceId).toLower().trimSpace(); download url param? 14 TabId int32 15 ItemType int32 16 SubType int32 // image type, 0 -> None 1 -> Magic Face 2 -> GIF 3 -> PNG 17 MediaType int32 // 1 -> Voice Face 2 -> dynamic face 18 EncryptKey []byte // tea + xor, see EMosmUtils.class::a maybe useful? 19 MagicValue string 20 } 21 22 type DiceElement struct { 23 *MarketFaceElement 24 Value int32 25 } 26 27 func (e *MarketFaceElement) Type() ElementType { 28 return Face 29 } 30 31 func (e *MarketFaceElement) Pack() []*msg.Elem { 32 return []*msg.Elem{ 33 { 34 MarketFace: &msg.MarketFace{ 35 FaceName: utils.S2B(e.Name), 36 ItemType: proto.Uint32(uint32(e.ItemType)), 37 FaceInfo: proto.Uint32(1), 38 FaceId: e.FaceId, 39 TabId: proto.Uint32(uint32(e.TabId)), 40 SubType: proto.Uint32(uint32(e.SubType)), 41 Key: e.EncryptKey, 42 MediaType: proto.Uint32(uint32(e.MediaType)), 43 ImageWidth: proto.Uint32(200), 44 ImageHeight: proto.Uint32(200), 45 Mobileparam: utils.S2B(e.MagicValue), 46 }, 47 }, 48 { 49 Text: &msg.Text{Str: proto.Some(e.Name)}, 50 }, 51 } 52 } 53 54 func NewDice(value int32) IMessageElement { 55 if value < 1 || value > 6 { 56 return nil 57 } 58 return &MarketFaceElement{ 59 Name: "[骰子]", 60 FaceId: []byte{72, 35, 211, 173, 177, 93, 240, 128, 20, 206, 93, 103, 150, 183, 110, 225}, 61 TabId: 11464, 62 ItemType: 6, 63 SubType: 3, 64 MediaType: 0, 65 EncryptKey: []byte{52, 48, 57, 101, 50, 97, 54, 57, 98, 49, 54, 57, 49, 56, 102, 57}, 66 MagicValue: fmt.Sprintf("rscType?1;value=%v", value-1), 67 } 68 } 69 70 type FingerGuessingElement struct { 71 *MarketFaceElement 72 Value int32 73 Name string 74 } 75 76 var fingerGuessingName = map[int32]string{ 77 0: "石头", 78 1: "剪刀", 79 2: "布", 80 } 81 82 func NewFingerGuessing(value int32) IMessageElement { 83 // value 0石头, 1剪子, 2布 84 if value < 0 || value > 2 { 85 return nil 86 } 87 return &MarketFaceElement{ 88 Name: "[猜拳]", 89 FaceId: []byte{131, 200, 162, 147, 174, 101, 202, 20, 15, 52, 129, 32, 167, 116, 72, 238}, 90 TabId: 11415, 91 ItemType: 6, 92 SubType: 3, 93 MediaType: 0, 94 EncryptKey: []byte{55, 100, 101, 51, 57, 102, 101, 98, 99, 102, 52, 53, 101, 54, 100, 98}, 95 MagicValue: fmt.Sprintf("rscType?1;value=%v", value), 96 } 97 }