mirror of
https://github.com/AynaLivePlayer/blivedm-go.git
synced 2025-12-06 19:32:49 +08:00
@@ -21,7 +21,8 @@ type eventHandlers struct {
|
|||||||
superChatHandlers []func(*message.SuperChat)
|
superChatHandlers []func(*message.SuperChat)
|
||||||
giftHandlers []func(*message.Gift)
|
giftHandlers []func(*message.Gift)
|
||||||
guardBuyHandlers []func(*message.GuardBuy)
|
guardBuyHandlers []func(*message.GuardBuy)
|
||||||
liveHandlers []func(*message.Live)
|
liveStartHandlers []func(start *message.LiveStart)
|
||||||
|
liveStopHandlers []func(start *message.LiveStop)
|
||||||
userToastHandlers []func(*message.UserToast)
|
userToastHandlers []func(*message.UserToast)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,11 +62,17 @@ func (c *Client) OnGuardBuy(f func(*message.GuardBuy)) {
|
|||||||
c.eventHandlers.guardBuyHandlers = append(c.eventHandlers.guardBuyHandlers, f)
|
c.eventHandlers.guardBuyHandlers = append(c.eventHandlers.guardBuyHandlers, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnLive 添加 开播事件 的处理器
|
// OnLiveStart 添加 开播事件 的处理器
|
||||||
func (c *Client) OnLive(f func(*message.Live)) {
|
func (c *Client) OnLiveStart(f func(start *message.LiveStart)) {
|
||||||
c.eventHandlers.liveHandlers = append(c.eventHandlers.liveHandlers, f)
|
c.eventHandlers.liveStartHandlers = append(c.eventHandlers.liveStartHandlers, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OnLiveStop 添加 关播事件 的处理器
|
||||||
|
func (c *Client) OnLiveStop(f func(start *message.LiveStop)) {
|
||||||
|
c.eventHandlers.liveStopHandlers = append(c.eventHandlers.liveStopHandlers, f)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnUserToast 添加 UserToast 的处理
|
||||||
// OnUserToast 添加 UserToast 的处理器
|
// OnUserToast 添加 UserToast 的处理器
|
||||||
func (c *Client) OnUserToast(f func(*message.UserToast)) {
|
func (c *Client) OnUserToast(f func(*message.UserToast)) {
|
||||||
c.eventHandlers.userToastHandlers = append(c.eventHandlers.userToastHandlers, f)
|
c.eventHandlers.userToastHandlers = append(c.eventHandlers.userToastHandlers, f)
|
||||||
@@ -88,36 +95,49 @@ func (c *Client) Handle(p packet.Packet) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch cmd {
|
switch cmd {
|
||||||
|
// 弹幕
|
||||||
case "DANMU_MSG":
|
case "DANMU_MSG":
|
||||||
d := new(message.Danmaku)
|
d := new(message.Danmaku)
|
||||||
d.Parse(p.Body)
|
d.Parse(p.Body)
|
||||||
for _, fn := range c.eventHandlers.danmakuMessageHandlers {
|
for _, fn := range c.eventHandlers.danmakuMessageHandlers {
|
||||||
go cover(func() { fn(d) })
|
go cover(func() { fn(d) })
|
||||||
}
|
}
|
||||||
|
// 醒目留言
|
||||||
case "SUPER_CHAT_MESSAGE":
|
case "SUPER_CHAT_MESSAGE":
|
||||||
s := new(message.SuperChat)
|
s := new(message.SuperChat)
|
||||||
s.Parse(p.Body)
|
s.Parse(p.Body)
|
||||||
for _, fn := range c.eventHandlers.superChatHandlers {
|
for _, fn := range c.eventHandlers.superChatHandlers {
|
||||||
go cover(func() { fn(s) })
|
go cover(func() { fn(s) })
|
||||||
}
|
}
|
||||||
|
// 礼物
|
||||||
case "SEND_GIFT":
|
case "SEND_GIFT":
|
||||||
g := new(message.Gift)
|
g := new(message.Gift)
|
||||||
g.Parse(p.Body)
|
g.Parse(p.Body)
|
||||||
for _, fn := range c.eventHandlers.giftHandlers {
|
for _, fn := range c.eventHandlers.giftHandlers {
|
||||||
go cover(func() { fn(g) })
|
go cover(func() { fn(g) })
|
||||||
}
|
}
|
||||||
|
// 大航海
|
||||||
case "GUARD_BUY":
|
case "GUARD_BUY":
|
||||||
g := new(message.GuardBuy)
|
g := new(message.GuardBuy)
|
||||||
g.Parse(p.Body)
|
g.Parse(p.Body)
|
||||||
for _, fn := range c.eventHandlers.guardBuyHandlers {
|
for _, fn := range c.eventHandlers.guardBuyHandlers {
|
||||||
go cover(func() { fn(g) })
|
go cover(func() { fn(g) })
|
||||||
}
|
}
|
||||||
|
// 开播
|
||||||
case "LIVE":
|
case "LIVE":
|
||||||
l := new(message.Live)
|
l := new(message.LiveStart)
|
||||||
l.Parse(p.Body)
|
l.Parse(p.Body)
|
||||||
for _, fn := range c.eventHandlers.liveHandlers {
|
for _, fn := range c.eventHandlers.liveStartHandlers {
|
||||||
go cover(func() { fn(l) })
|
go cover(func() { fn(l) })
|
||||||
}
|
}
|
||||||
|
//下播
|
||||||
|
case "PREPARING":
|
||||||
|
l := new(message.LiveStop)
|
||||||
|
l.Parse(p.Body)
|
||||||
|
for _, fn := range c.eventHandlers.liveStopHandlers {
|
||||||
|
go cover(func() { fn(l) })
|
||||||
|
}
|
||||||
|
// 用户 toast
|
||||||
case "USER_TOAST_MSG":
|
case "USER_TOAST_MSG":
|
||||||
u := new(message.UserToast)
|
u := new(message.UserToast)
|
||||||
u.Parse(p.Body)
|
u.Parse(p.Body)
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
c := client.NewClient(6)
|
c := client.NewClient(23943357)
|
||||||
c.SetCookie("this is a example cookie.")
|
c.SetCookie("")
|
||||||
//弹幕事件
|
//弹幕事件
|
||||||
c.OnDanmaku(func(danmaku *message.Danmaku) {
|
c.OnDanmaku(func(danmaku *message.Danmaku) {
|
||||||
if danmaku.Type == message.EmoticonDanmaku {
|
if danmaku.Type == message.EmoticonDanmaku {
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ func (d *Danmaku) Parse(data []byte) {
|
|||||||
|
|
||||||
ext := new(Extra)
|
ext := new(Extra)
|
||||||
emo := new(Emoticon)
|
emo := new(Emoticon)
|
||||||
|
//扩展字段
|
||||||
err := utils.UnmarshalStr(info.Get("0.15.extra").String(), ext)
|
err := utils.UnmarshalStr(info.Get("0.15.extra").String(), ext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("parse danmaku extra failed")
|
log.Error("parse danmaku extra failed")
|
||||||
@@ -77,27 +78,30 @@ func (d *Danmaku) Parse(data []byte) {
|
|||||||
}
|
}
|
||||||
i2 := info.Get("2")
|
i2 := info.Get("2")
|
||||||
i3 := info.Get("3")
|
i3 := info.Get("3")
|
||||||
d.Content = info.Get("1").String()
|
d.Content = info.Get("1").String() //弹幕内容
|
||||||
d.Sender = &User{
|
|
||||||
Uid: int(i2.Get("0").Int()),
|
d.Sender = &User{ //用户信息
|
||||||
Uname: i2.Get("1").String(),
|
Uid: int(i2.Get("0").Int()), //用户uid
|
||||||
Admin: i2.Get("2").Bool(),
|
Uname: i2.Get("1").String(), //用户昵称
|
||||||
|
UserLevel: i2.Get("16.0").Int(), //用户等级
|
||||||
|
Admin: i2.Get("2").Bool(), //是否为管理者
|
||||||
Urank: int(i2.Get("5").Int()),
|
Urank: int(i2.Get("5").Int()),
|
||||||
MobileVerify: i2.Get("6").Bool(),
|
MobileVerify: i2.Get("6").Bool(), //是否绑定手机
|
||||||
GuardLevel: int(info.Get("7").Int()),
|
GuardLevel: int(info.Get("7").Int()), //舰队等级
|
||||||
|
//勋章信息
|
||||||
Medal: &Medal{
|
Medal: &Medal{
|
||||||
Level: int(i3.Get("0").Int()),
|
Level: int(i3.Get("0").Int()), //勋章等级
|
||||||
Name: i3.Get("1").String(),
|
Name: i3.Get("1").String(), //勋章名称
|
||||||
UpName: i3.Get("2").String(),
|
UpName: i3.Get("2").String(), //勋章上主播昵称
|
||||||
UpRoomId: int(i3.Get("3").Int()),
|
UpRoomId: int(i3.Get("3").Int()), //上主播房间id
|
||||||
Color: int(i3.Get("4").Int()),
|
Color: int(i3.Get("4").Int()), //勋章颜色
|
||||||
UpUid: int(i3.Get("12").Int()),
|
UpUid: int(i3.Get("12").Int()), //上主播uid
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
d.Extra = ext
|
d.Extra = ext
|
||||||
d.Emoticon = emo
|
d.Emoticon = emo
|
||||||
d.Type = int(info.Get("0.12").Int())
|
d.Type = int(info.Get("0.12").Int()) //弹幕类型
|
||||||
d.Timestamp = info.Get("0.4").Int()
|
d.Timestamp = info.Get("0.4").Int() //时间戳
|
||||||
d.Raw = sb
|
d.Raw = sb
|
||||||
|
|
||||||
dmv2Content := parsed.Get("dm_v2").String()
|
dmv2Content := parsed.Get("dm_v2").String()
|
||||||
|
|||||||
189
message/gift.go
189
message/gift.go
@@ -6,109 +6,112 @@ import (
|
|||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 礼物消息结构体
|
||||||
type Gift struct {
|
type Gift struct {
|
||||||
Action string `json:"action"`
|
Action string `json:"action"` // 操作类型
|
||||||
BatchComboId string `json:"batch_combo_id"`
|
BatchComboId string `json:"batch_combo_id"` // 批量组合ID
|
||||||
BatchComboSend interface{} `json:"batch_combo_send"`
|
BatchComboSend interface{} `json:"batch_combo_send"` // 批量组合发送信息
|
||||||
BeatId string `json:"beatId"`
|
BeatId string `json:"beatId"` // Beat ID
|
||||||
BizSource string `json:"biz_source"`
|
BizSource string `json:"biz_source"` // 业务来源
|
||||||
BlindGift interface{} `json:"blind_gift"`
|
BlindGift interface{} `json:"blind_gift"` // 盲盒礼物信息
|
||||||
BroadcastId int `json:"broadcast_id"`
|
BroadcastId int `json:"broadcast_id"` // 广播ID
|
||||||
CoinType string `json:"coin_type"`
|
CoinType string `json:"coin_type"` // 币种类型
|
||||||
ComboResourcesId int `json:"combo_resources_id"`
|
ComboResourcesId int `json:"combo_resources_id"` // 组合资源ID
|
||||||
ComboSend interface{} `json:"combo_send"`
|
ComboSend interface{} `json:"combo_send"` // 组合发送信息
|
||||||
ComboStayTime int `json:"combo_stay_time"`
|
ComboStayTime int `json:"combo_stay_time"` // 组合停留时间
|
||||||
ComboTotalCoin int `json:"combo_total_coin"`
|
ComboTotalCoin int `json:"combo_total_coin"` // 组合总硬币数
|
||||||
CritProb int `json:"crit_prob"`
|
CritProb int `json:"crit_prob"` // 批判概率
|
||||||
Demarcation int `json:"demarcation"`
|
Demarcation int `json:"demarcation"` // 分界线
|
||||||
DiscountPrice int `json:"discount_price"`
|
DiscountPrice int `json:"discount_price"` // 折扣价格
|
||||||
Dmscore int `json:"dmscore"`
|
Dmscore int `json:"dmscore"` // DM分数
|
||||||
Draw int `json:"draw"`
|
Draw int `json:"draw"` // 抽奖
|
||||||
Effect int `json:"effect"`
|
Effect int `json:"effect"` // 效果
|
||||||
EffectBlock int `json:"effect_block"`
|
EffectBlock int `json:"effect_block"` // 效果块
|
||||||
Face string `json:"face"`
|
Face string `json:"face"` // 头像URL
|
||||||
FloatScResourceId int `json:"float_sc_resource_id"`
|
FloatScResourceId int `json:"float_sc_resource_id"` // 浮动资源ID
|
||||||
GiftId int `json:"giftId"`
|
GiftId int `json:"giftId"` // 礼物ID
|
||||||
GiftName string `json:"giftName"`
|
GiftName string `json:"giftName"` // 礼物名称
|
||||||
GiftType int `json:"giftType"`
|
GiftType int `json:"giftType"` // 礼物类型
|
||||||
Gold int `json:"gold"`
|
Gold int `json:"gold"` // 金币数量
|
||||||
GuardLevel int `json:"guard_level"`
|
GuardLevel int `json:"guard_level"` // 守护等级
|
||||||
IsFirst bool `json:"is_first"`
|
IsFirst bool `json:"is_first"` // 是否首次赠送
|
||||||
IsSpecialBatch int `json:"is_special_batch"`
|
IsSpecialBatch int `json:"is_special_batch"` // 是否特殊批量
|
||||||
Magnification float64 `json:"magnification"`
|
Magnification float64 `json:"magnification"` // 放大倍数
|
||||||
MedalInfo struct {
|
MedalInfo struct {
|
||||||
AnchorRoomid int `json:"anchor_roomid"`
|
AnchorRoomid int `json:"anchor_roomid"` // 主播房间ID
|
||||||
AnchorUname string `json:"anchor_uname"`
|
AnchorUname string `json:"anchor_uname"` // 主播用户名
|
||||||
GuardLevel int `json:"guard_level"`
|
GuardLevel int `json:"guard_level"` // 守护等级
|
||||||
IconId int `json:"icon_id"`
|
IconId int `json:"icon_id"` // 图标ID
|
||||||
IsLighted int `json:"is_lighted"`
|
IsLighted int `json:"is_lighted"` // 是否点亮
|
||||||
MedalColor int `json:"medal_color"`
|
MedalColor int `json:"medal_color"` // 勋章颜色
|
||||||
MedalColorBorder int `json:"medal_color_border"`
|
MedalColorBorder int `json:"medal_color_border"` // 勋章边框颜色
|
||||||
MedalColorEnd int `json:"medal_color_end"`
|
MedalColorEnd int `json:"medal_color_end"` // 勋章结束颜色
|
||||||
MedalColorStart int `json:"medal_color_start"`
|
MedalColorStart int `json:"medal_color_start"` // 勋章开始颜色
|
||||||
MedalLevel int `json:"medal_level"`
|
MedalLevel int `json:"medal_level"` // 勋章等级
|
||||||
MedalName string `json:"medal_name"`
|
MedalName string `json:"medal_name"` // 勋章名称
|
||||||
Special string `json:"special"`
|
Special string `json:"special"` // 特殊标记
|
||||||
TargetId int `json:"target_id"`
|
TargetId int `json:"target_id"` // 目标ID
|
||||||
} `json:"medal_info"`
|
} `json:"medal_info"`
|
||||||
NameColor string `json:"name_color"`
|
NameColor string `json:"name_color"` // 名称颜色
|
||||||
Num int `json:"num"`
|
Num int `json:"num"` // 数量
|
||||||
OriginalGiftName string `json:"original_gift_name"`
|
OriginalGiftName string `json:"original_gift_name"` // 原始礼物名称
|
||||||
Price int `json:"price"`
|
Price int `json:"price"` // 价格
|
||||||
Rcost int `json:"rcost"`
|
Rcost int `json:"rcost"` // 实际花费
|
||||||
Remain int `json:"remain"`
|
Remain int `json:"remain"` // 剩余数量
|
||||||
Rnd string `json:"rnd"`
|
Rnd string `json:"rnd"` // 随机数
|
||||||
SendMaster interface{} `json:"send_master"`
|
SendMaster interface{} `json:"send_master"` // 发送者信息
|
||||||
Silver int `json:"silver"`
|
Silver int `json:"silver"` // 银币数量
|
||||||
Super int `json:"super"`
|
Super int `json:"super"` // 是否超级礼物
|
||||||
SuperBatchGiftNum int `json:"super_batch_gift_num"`
|
SuperBatchGiftNum int `json:"super_batch_gift_num"` // 超级批量礼物数量
|
||||||
SuperGiftNum int `json:"super_gift_num"`
|
SuperGiftNum int `json:"super_gift_num"` // 超级礼物数量
|
||||||
SvgaBlock int `json:"svga_block"`
|
SvgaBlock int `json:"svga_block"` // SVGA块
|
||||||
TagImage string `json:"tag_image"`
|
TagImage string `json:"tag_image"` // 标签图片URL
|
||||||
Tid string `json:"tid"`
|
Tid string `json:"tid"` // TID
|
||||||
Timestamp int `json:"timestamp"`
|
Timestamp int `json:"timestamp"` // 时间戳
|
||||||
TopList interface{} `json:"top_list"`
|
TopList interface{} `json:"top_list"` // 顶级列表
|
||||||
TotalCoin int `json:"total_coin"`
|
TotalCoin int `json:"total_coin"` // 总硬币数
|
||||||
Uid int `json:"uid"`
|
Uid int `json:"uid"` // 用户ID
|
||||||
Uname string `json:"uname"`
|
Uname string `json:"uname"` // 用户名
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 组合发送结构体
|
||||||
type ComboSend struct {
|
type ComboSend struct {
|
||||||
Action string `json:"action"`
|
Action string `json:"action"` // 操作类型
|
||||||
BatchComboId string `json:"batch_combo_id"`
|
BatchComboId string `json:"batch_combo_id"` // 批量组合ID
|
||||||
BatchComboNum int `json:"batch_combo_num"`
|
BatchComboNum int `json:"batch_combo_num"` // 批量组合数量
|
||||||
ComboId string `json:"combo_id"`
|
ComboId string `json:"combo_id"` // 组合ID
|
||||||
ComboNum int `json:"combo_num"`
|
ComboNum int `json:"combo_num"` // 组合数量
|
||||||
ComboTotalCoin int `json:"combo_total_coin"`
|
ComboTotalCoin int `json:"combo_total_coin"` // 组合总硬币数
|
||||||
Dmscore int `json:"dmscore"`
|
Dmscore int `json:"dmscore"` // DM分数
|
||||||
GiftId int `json:"gift_id"`
|
GiftId int `json:"gift_id"` // 礼物ID
|
||||||
GiftName string `json:"gift_name"`
|
GiftName string `json:"gift_name"` // 礼物名称
|
||||||
GiftNum int `json:"gift_num"`
|
GiftNum int `json:"gift_num"` // 礼物数量
|
||||||
IsShow int `json:"is_show"`
|
IsShow int `json:"is_show"` // 是否显示
|
||||||
MedalInfo struct {
|
MedalInfo struct {
|
||||||
AnchorRoomid int `json:"anchor_roomid"`
|
AnchorRoomid int `json:"anchor_roomid"` // 主播房间ID
|
||||||
AnchorUname string `json:"anchor_uname"`
|
AnchorUname string `json:"anchor_uname"` // 主播用户名
|
||||||
GuardLevel int `json:"guard_level"`
|
GuardLevel int `json:"guard_level"` // 守护等级
|
||||||
IconId int `json:"icon_id"`
|
IconId int `json:"icon_id"` // 图标ID
|
||||||
IsLighted int `json:"is_lighted"`
|
IsLighted int `json:"is_lighted"` // 是否点亮
|
||||||
MedalColor int `json:"medal_color"`
|
MedalColor int `json:"medal_color"` // 勋章颜色
|
||||||
MedalColorBorder int `json:"medal_color_border"`
|
MedalColorBorder int `json:"medal_color_border"` // 勋章边框颜色
|
||||||
MedalColorEnd int `json:"medal_color_end"`
|
MedalColorEnd int `json:"medal_color_end"` // 勋章结束颜色
|
||||||
MedalColorStart int `json:"medal_color_start"`
|
MedalColorStart int `json:"medal_color_start"` // 勋章开始颜色
|
||||||
MedalLevel int `json:"medal_level"`
|
MedalLevel int `json:"medal_level"` // 勋章等级
|
||||||
MedalName string `json:"medal_name"`
|
MedalName string `json:"medal_name"` // 勋章名称
|
||||||
Special string `json:"special"`
|
Special string `json:"special"` // 特殊标记
|
||||||
TargetId int `json:"target_id"`
|
TargetId int `json:"target_id"` // 目标ID
|
||||||
} `json:"medal_info"`
|
} `json:"medal_info"`
|
||||||
NameColor string `json:"name_color"`
|
NameColor string `json:"name_color"` // 名称颜色
|
||||||
RUname string `json:"r_uname"`
|
RUname string `json:"r_uname"` // 接收者用户名
|
||||||
Ruid int `json:"ruid"`
|
Ruid int `json:"ruid"` // 接收者用户ID
|
||||||
SendMaster interface{} `json:"send_master"`
|
SendMaster interface{} `json:"send_master"` // 发送者信息
|
||||||
TotalNum int `json:"total_num"`
|
TotalNum int `json:"total_num"` // 总数量
|
||||||
Uid int `json:"uid"`
|
Uid int `json:"uid"` // 用户ID
|
||||||
Uname string `json:"uname"`
|
Uname string `json:"uname"` // 用户名
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 解析礼物消息数据
|
||||||
func (g *Gift) Parse(data []byte) {
|
func (g *Gift) Parse(data []byte) {
|
||||||
sb := utils.BytesToString(data)
|
sb := utils.BytesToString(data)
|
||||||
sd := gjson.Get(sb, "data").String()
|
sd := gjson.Get(sb, "data").String()
|
||||||
|
|||||||
@@ -6,16 +6,17 @@ import (
|
|||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GuardBuy 购买守护消息结构体
|
||||||
type GuardBuy struct {
|
type GuardBuy struct {
|
||||||
Uid int `json:"uid"`
|
Uid int `json:"uid"` // 用户ID
|
||||||
Username string `json:"username"`
|
Username string `json:"username"` // 用户名
|
||||||
GuardLevel int `json:"guard_level"`
|
GuardLevel int `json:"guard_level"` // 守护等级
|
||||||
Num int `json:"num"`
|
Num int `json:"num"` // 数量
|
||||||
Price int `json:"price"`
|
Price int `json:"price"` // 价格
|
||||||
GiftId int `json:"gift_id"`
|
GiftId int `json:"gift_id"` // 礼物ID
|
||||||
GiftName string `json:"gift_name"`
|
GiftName string `json:"gift_name"` // 礼物名称
|
||||||
StartTime int `json:"start_time"`
|
StartTime int `json:"start_time"` // 开始时间戳
|
||||||
EndTime int `json:"end_time"`
|
EndTime int `json:"end_time"` // 结束时间戳
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GuardBuy) Parse(data []byte) {
|
func (g *GuardBuy) Parse(data []byte) {
|
||||||
|
|||||||
@@ -5,27 +5,47 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// StopLiveRoomList 停止直播房间列表结构体
|
||||||
type StopLiveRoomList struct {
|
type StopLiveRoomList struct {
|
||||||
RoomIdList []int `json:"room_id_list"`
|
RoomIdList []int `json:"room_id_list"` // 房间ID列表
|
||||||
}
|
}
|
||||||
|
|
||||||
type Live struct {
|
// Live 直播消息结构体
|
||||||
Cmd string `json:"cmd"`
|
type LiveStart struct {
|
||||||
LiveKey string `json:"live_key"`
|
Cmd string `json:"cmd"` // 命令
|
||||||
VoiceBackground string `json:"voice_background"`
|
LiveKey string `json:"live_key"` // 直播密钥
|
||||||
SubSessionKey string `json:"sub_session_key"`
|
VoiceBackground string `json:"voice_background"` // 语音背景
|
||||||
LivePlatform string `json:"live_platform"`
|
SubSessionKey string `json:"sub_session_key"` // 子会话密钥
|
||||||
LiveModel int `json:"live_model"`
|
LivePlatform string `json:"live_platform"` // 直播平台
|
||||||
LiveTime int `json:"live_time"`
|
LiveModel int `json:"live_model"` // 直播模式
|
||||||
Roomid int `json:"roomid"`
|
LiveTime int `json:"live_time"` // 直播时间
|
||||||
|
Roomid int `json:"roomid"` // 房间ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 停止直播
|
||||||
|
type LiveStop struct {
|
||||||
|
Cmd string `json:"cmd"`
|
||||||
|
MsgId string `json:"msg_id"`
|
||||||
|
PIsAck bool `json:"p_is_ack"`
|
||||||
|
PMsgType int `json:"p_msg_type"`
|
||||||
|
Roomid string `json:"roomid"`
|
||||||
|
Round int `json:"round"` //开启轮播时存在,轮播状态: 1正在轮播 0未轮播
|
||||||
|
SendTime int64 `json:"send_time"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preparing 直播准备中消息结构体
|
||||||
type Preparing struct {
|
type Preparing struct {
|
||||||
Cmd string `json:"cmd"`
|
Cmd string `json:"cmd"` // 命令
|
||||||
Roomid string `json:"roomid"`
|
Roomid string `json:"roomid"` // 房间ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Live) Parse(data []byte) {
|
func (l *LiveStart) Parse(data []byte) {
|
||||||
|
err := json.Unmarshal(data, l)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("parse live failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (l *LiveStop) Parse(data []byte) {
|
||||||
err := json.Unmarshal(data, l)
|
err := json.Unmarshal(data, l)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("parse live failed")
|
log.Error("parse live failed")
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SuperChat
|
// SuperChat 超级弹幕消息结构体
|
||||||
// message_jpn: 消息日文翻译(目前只出现在SUPER_CHAT_MESSAGE_JPN)
|
// message_jpn: 消息日文翻译(目前只出现在SUPER_CHAT_MESSAGE_JPN)
|
||||||
// id_: str,消息ID,删除时用
|
// id_: str,消息ID,删除时用
|
||||||
type SuperChat struct {
|
type SuperChat struct {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ type User struct {
|
|||||||
MobileVerify bool
|
MobileVerify bool
|
||||||
Medal *Medal
|
Medal *Medal
|
||||||
GuardLevel int
|
GuardLevel int
|
||||||
|
UserLevel int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type Medal struct {
|
type Medal struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user