update medal struct

This commit is contained in:
aynakeya
2025-10-10 00:04:25 +08:00
parent f919c79c72
commit a4b25bc0c5
8 changed files with 73 additions and 15 deletions

View File

@@ -102,23 +102,43 @@ func (d *Danmaku) Parse(data []byte) {
i2 := info.Get("2")
i3 := info.Get("3")
d.Content = info.Get("1").String() //弹幕内容
// medal extra
v2colors := []uint32{0, 0, 0, 0, 0}
medalJson := info.Get("0.15.user.medal")
v2colors[0] = utils.HexToUint32(medalJson.Get("v2_medal_color_level").String(), 1)
v2colors[1] = utils.HexToUint32(medalJson.Get("v2_medal_color_start").String(), 1)
v2colors[2] = utils.HexToUint32(medalJson.Get("v2_medal_color_end").String(), 1)
v2colors[3] = utils.HexToUint32(medalJson.Get("v2_medal_color_border").String(), 1)
v2colors[4] = utils.HexToUint32(medalJson.Get("v2_medal_color_text").String(), 1)
// if no medal, i3 is 0 length array
d.Sender = &User{ //用户信息
Uid: int(i2.Get("0").Int()), //用户uid
Uname: i2.Get("1").String(), //用户昵称
UserLevel: i2.Get("16.0").Int(), //用户等级
UserLevel: info.Get("16.0").Int(), //用户等级
Admin: i2.Get("2").Bool(), //是否为管理者
Urank: int(i2.Get("5").Int()),
MobileVerify: i2.Get("6").Bool(), //是否绑定手机
GuardLevel: int(info.Get("7").Int()), //舰队等级
UserColor: utils.HexToUint32(i2.Get("7").String(), 1),
//勋章信息
Medal: &Medal{
Level: int(i3.Get("0").Int()), //勋章等级
Name: i3.Get("1").String(), //勋章名称
UpName: i3.Get("2").String(), //勋章上主播昵称
UpRoomId: int(i3.Get("3").Int()), //上主播房间id
Color: int(i3.Get("4").Int()), //勋章颜色
UpUid: int(i3.Get("12").Int()), //上主播uid
Level: int(i3.Get("0").Int()), //勋章等级
Name: i3.Get("1").String(), //勋章名称
UpName: i3.Get("2").String(), //勋章上主播昵称
UpRoomId: int(i3.Get("3").Int()), //上主播房间id
Color: int(i3.Get("4").Int()), //勋章颜色
ColorStart: int(i3.Get("7").Int()), //勋章开始颜色
ColorEnd: int(i3.Get("8").Int()), //勋章结束颜色
ColorBorder: int(i3.Get("9").Int()), //勋章边框颜色
IsLight: i3.Get("11").Int() == 1, //勋章是否为点亮的
UpUid: int(i3.Get("12").Int()), //上主播uid
V2ColorLevel: v2colors[0],
V2ColorStart: v2colors[1],
V2ColorEnd: v2colors[2],
V2ColorBorder: v2colors[3],
V2ColorText: v2colors[4],
},
}
d.Extra = ext

View File

@@ -67,7 +67,7 @@ type Gift struct {
SvgaBlock int `json:"svga_block"` // SVGA块
TagImage string `json:"tag_image"` // 标签图片URL
Tid string `json:"tid"` // TID
Timestamp int `json:"timestamp"` // 时间戳
Timestamp int64 `json:"timestamp"` // 时间戳
TopList interface{} `json:"top_list"` // 顶级列表
TotalCoin int `json:"total_coin"` // 总硬币数
Uid int `json:"uid"` // 用户ID

View File

@@ -52,7 +52,7 @@ type SuperChat struct {
Time int `json:"time"` //剩余时间
Token string `json:"token"`
TransMark int `json:"trans_mark"`
Ts int `json:"ts"`
Ts int64 `json:"ts"`
Uid int `json:"uid"` //用户ID
UserInfo struct {
Face string `json:"face"` //用户头像URL

View File

@@ -9,13 +9,23 @@ type User struct {
Medal *Medal
GuardLevel int
UserLevel int64
UserColor uint32 // rgb
}
type Medal struct {
Name string
Level int
Color int
UpRoomId int
UpUid int
UpName string
Name string
Level int
Color int
ColorStart int
ColorEnd int
ColorBorder int
UpRoomId int
UpUid int
UpName string
IsLight bool
V2ColorLevel uint32 // rgba
V2ColorStart uint32 // rgba
V2ColorEnd uint32 // rgba
V2ColorBorder uint32 // rgba
V2ColorText uint32 // rgba
}