1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

feat: support receive Animated Sticker

This commit is contained in:
wdvxdr 2021-11-19 23:02:24 +08:00
parent b9f70f7d4c
commit 3216c69d46
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
5 changed files with 36 additions and 10 deletions

View File

@ -103,6 +103,7 @@ type MusicShareElement struct {
type AnimatedSticker struct {
ID int32
Name string
}
type RedBagMessageType int

View File

@ -8,11 +8,11 @@ var faceMap = map[int]string{
2: "色",
3: "发呆",
4: "得意",
5: "流泪",
6: "害羞",
7: "闭嘴",
8: "睡",
9: "大哭",
5: "流泪",
10: "尴尬",
11: "发怒",
12: "调皮",
@ -128,6 +128,13 @@ var faceMap = map[int]string{
324: "吃糖",
325: "惊吓",
326: "生气",
53: "蛋糕",
114: "篮球",
327: "加一",
328: "错号",
329: "对号",
330: "完成",
331: "明白",
49: "拥抱",
66: "爱心",
63: "玫瑰",
@ -226,7 +233,6 @@ var faceMap = map[int]string{
274: "太南了",
113: "啤酒",
140: "K歌",
53: "蛋糕",
188: "蛋",
55: "炸弹",
184: "河蟹",
@ -238,7 +244,6 @@ var faceMap = map[int]string{
145: "祈祷",
117: "瓢虫",
168: "药",
114: "篮球",
115: "乒乓",
57: "足球",
41: "发抖",
@ -260,6 +265,7 @@ var faceMap = map[int]string{
}
var stickerMap = map[int]string{
5: "16",
311: "1",
312: "2",
313: "3",
@ -274,4 +280,6 @@ var stickerMap = map[int]string{
324: "12",
325: "14",
326: "15",
53: "17",
114: "13",
}

View File

@ -15,7 +15,7 @@ import (
"strings"
)
const faceDownloadUrl = `https://down.qq.com/qqface/config/face_config2021071501.zip?mType=Other` //? 好像是会自动更新的
const faceDownloadUrl = `https://down.qq.com/qqface/config/face_config_json_1026_hide.zip?mType=Other` //? 好像是会自动更新的
type ani struct {
QSid string
@ -66,7 +66,7 @@ func main() {
faceConfig.SystemFace[i].QDes = strings.TrimPrefix(faceConfig.SystemFace[i].QDes, "/")
if sysface.AniStickerId != "" {
faceConfig.Stickers = append(faceConfig.Stickers, ani{
Qsid: sysface.QSid,
QSid: sysface.QSid,
StickerID: sysface.AniStickerId,
})
}

View File

@ -567,6 +567,14 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
newSysFaceMsg := &msg.MsgElemInfoServtype33{}
_ = proto.Unmarshal(elem.CommonElem.PbElem, newSysFaceMsg)
res = append(res, NewFace(int32(newSysFaceMsg.GetIndex())))
case 37:
animatedStickerMsg := &msg.MsgElemInfoServtype37{}
_ = proto.Unmarshal(elem.CommonElem.PbElem, animatedStickerMsg)
sticker := &AnimatedSticker{
ID: int32(animatedStickerMsg.GetQsid()),
Name: strings.TrimPrefix(string(animatedStickerMsg.GetText()), "/"),
}
return []IMessageElement{sticker} // sticker 永远为单独消息
}
}
}

View File

@ -155,13 +155,22 @@ func (e *ShortVideoElement) Pack() (r []*msg.Elem) {
}
func (e *AnimatedSticker) Pack() []*msg.Elem {
name := "/" + faceMap[int(e.ID)]
if e.Name == "" {
e.Name = faceMap[int(e.ID)]
}
name := "/" + e.Name
business := int32(1)
if e.ID == 114 {
// 对篮球适配,否则篮球不会投出
business = 2
}
pbElem, _ := proto.Marshal(&msg.MsgElemInfoServtype37{
Packid: []byte("1"),
Stickerid: []byte(stickerMap[int(e.ID)]),
Qsid: proto.Uint32(uint32(e.ID)),
Sourcetype: proto.Uint32(1),
Stickertype: proto.Uint32(1),
Stickertype: proto.Uint32(uint32(business)),
Resultid: []byte{},
Text: []byte(name),
Surpriseid: []byte{},
@ -171,11 +180,11 @@ func (e *AnimatedSticker) Pack() []*msg.Elem {
CommonElem: &msg.CommonElem{
ServiceType: proto.Int32(37),
PbElem: pbElem,
BusinessType: proto.Int32(1),
BusinessType: &business,
},
}
pbReverse, _ := proto.Marshal(&msg.Text{Str: proto.String(fmt.Sprintf("[%s]请使用最新版手机QQ体验新功能", faceMap[int(e.ID)]))})
pbReverse, _ := proto.Marshal(&msg.Text{Str: proto.String(fmt.Sprintf("[%s]请使用最新版手机QQ体验新功能", e.Name))})
text := &msg.Elem{
Text: &msg.Text{
Str: &name,