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

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

View File

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

View File

@ -15,7 +15,7 @@ import (
"strings" "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 { type ani struct {
QSid string QSid string
@ -66,7 +66,7 @@ func main() {
faceConfig.SystemFace[i].QDes = strings.TrimPrefix(faceConfig.SystemFace[i].QDes, "/") faceConfig.SystemFace[i].QDes = strings.TrimPrefix(faceConfig.SystemFace[i].QDes, "/")
if sysface.AniStickerId != "" { if sysface.AniStickerId != "" {
faceConfig.Stickers = append(faceConfig.Stickers, ani{ faceConfig.Stickers = append(faceConfig.Stickers, ani{
Qsid: sysface.QSid, QSid: sysface.QSid,
StickerID: sysface.AniStickerId, StickerID: sysface.AniStickerId,
}) })
} }

View File

@ -567,6 +567,14 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
newSysFaceMsg := &msg.MsgElemInfoServtype33{} newSysFaceMsg := &msg.MsgElemInfoServtype33{}
_ = proto.Unmarshal(elem.CommonElem.PbElem, newSysFaceMsg) _ = proto.Unmarshal(elem.CommonElem.PbElem, newSysFaceMsg)
res = append(res, NewFace(int32(newSysFaceMsg.GetIndex()))) 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 { 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{ pbElem, _ := proto.Marshal(&msg.MsgElemInfoServtype37{
Packid: []byte("1"), Packid: []byte("1"),
Stickerid: []byte(stickerMap[int(e.ID)]), Stickerid: []byte(stickerMap[int(e.ID)]),
Qsid: proto.Uint32(uint32(e.ID)), Qsid: proto.Uint32(uint32(e.ID)),
Sourcetype: proto.Uint32(1), Sourcetype: proto.Uint32(1),
Stickertype: proto.Uint32(1), Stickertype: proto.Uint32(uint32(business)),
Resultid: []byte{}, Resultid: []byte{},
Text: []byte(name), Text: []byte(name),
Surpriseid: []byte{}, Surpriseid: []byte{},
@ -171,11 +180,11 @@ func (e *AnimatedSticker) Pack() []*msg.Elem {
CommonElem: &msg.CommonElem{ CommonElem: &msg.CommonElem{
ServiceType: proto.Int32(37), ServiceType: proto.Int32(37),
PbElem: pbElem, 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.Elem{
Text: &msg.Text{ Text: &msg.Text{
Str: &name, Str: &name,