mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
feat: supported dice face sending
This commit is contained in:
parent
742c4e7171
commit
d4d11202d6
@ -38,19 +38,6 @@ type FaceElement struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
type MarketFaceElement struct {
|
||||
Name string
|
||||
ItemType int32
|
||||
SubType int32
|
||||
EncryptKey []byte // tea + xor, see EMosmUtils.class::a maybe useful?
|
||||
MagicValue string
|
||||
}
|
||||
|
||||
type DiceElement struct {
|
||||
*MarketFaceElement
|
||||
Value int32
|
||||
}
|
||||
|
||||
type AtElement struct {
|
||||
Target int64
|
||||
Display string
|
||||
@ -237,10 +224,6 @@ func (e *FaceElement) Type() ElementType {
|
||||
return Face
|
||||
}
|
||||
|
||||
func (e *MarketFaceElement) Type() ElementType {
|
||||
return Face
|
||||
}
|
||||
|
||||
func (e *AtElement) Type() ElementType {
|
||||
return At
|
||||
}
|
||||
|
67
message/marketface.go
Normal file
67
message/marketface.go
Normal file
@ -0,0 +1,67 @@
|
||||
package message
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
||||
"github.com/Mrs4s/MiraiGo/utils"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type MarketFaceElement struct {
|
||||
Name string
|
||||
FaceId []byte // decoded = mediaType == 2 ? string(FaceId) : hex.EncodeToString(FaceId).toLower().trimSpace(); download url param?
|
||||
TabId int32
|
||||
ItemType int32
|
||||
SubType int32
|
||||
MediaType int32
|
||||
EncryptKey []byte // tea + xor, see EMosmUtils.class::a maybe useful?
|
||||
MagicValue string
|
||||
}
|
||||
|
||||
type DiceElement struct {
|
||||
*MarketFaceElement
|
||||
Value int32
|
||||
}
|
||||
|
||||
func (e *MarketFaceElement) Type() ElementType {
|
||||
return Face
|
||||
}
|
||||
|
||||
func (e *MarketFaceElement) Pack() []*msg.Elem {
|
||||
return []*msg.Elem{
|
||||
{
|
||||
MarketFace: &msg.MarketFace{
|
||||
FaceName: utils.S2B(e.Name),
|
||||
ItemType: proto.Uint32(uint32(e.ItemType)),
|
||||
FaceInfo: proto.Uint32(1),
|
||||
FaceId: e.FaceId,
|
||||
TabId: proto.Uint32(uint32(e.TabId)),
|
||||
SubType: proto.Uint32(uint32(e.SubType)),
|
||||
Key: e.EncryptKey,
|
||||
MediaType: proto.Uint32(uint32(e.MediaType)),
|
||||
ImageWidth: proto.Uint32(200),
|
||||
ImageHeight: proto.Uint32(200),
|
||||
Mobileparam: utils.S2B(e.MagicValue),
|
||||
},
|
||||
},
|
||||
{
|
||||
Text: &msg.Text{Str: &e.Name},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewDice(value int32) IMessageElement {
|
||||
if value < 1 || value > 6 {
|
||||
return nil
|
||||
}
|
||||
return &MarketFaceElement{
|
||||
Name: "[骰子]",
|
||||
FaceId: []byte{72, 35, 211, 173, 177, 93, 240, 128, 20, 206, 93, 103, 150, 183, 110, 225},
|
||||
TabId: 11464,
|
||||
ItemType: 6,
|
||||
SubType: 3,
|
||||
MediaType: 0,
|
||||
EncryptKey: []byte{52, 48, 57, 101, 50, 97, 54, 57, 98, 49, 54, 57, 49, 56, 102, 57},
|
||||
MagicValue: fmt.Sprintf("rscType?1;value=%v", value-1),
|
||||
}
|
||||
}
|
@ -470,8 +470,11 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
|
||||
if elem.MarketFace != nil {
|
||||
face := &MarketFaceElement{
|
||||
Name: utils.B2S(elem.MarketFace.GetFaceName()),
|
||||
FaceId: elem.MarketFace.FaceId,
|
||||
TabId: int32(elem.MarketFace.GetTabId()),
|
||||
ItemType: int32(elem.MarketFace.GetItemType()),
|
||||
SubType: int32(elem.MarketFace.GetSubType()),
|
||||
MediaType: int32(elem.MarketFace.GetMediaType()),
|
||||
EncryptKey: elem.MarketFace.GetKey(),
|
||||
MagicValue: utils.B2S(elem.MarketFace.Mobileparam),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user