forked from Akegarasu/blivedm-go
/
gift.go
119 lines (115 loc) · 4.83 KB
/
gift.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package message
import (
"github.com/AynaLivePlayer/blivedm-go/utils"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
)
type Gift struct {
Action string `json:"action"`
BatchComboId string `json:"batch_combo_id"`
BatchComboSend interface{} `json:"batch_combo_send"`
BeatId string `json:"beatId"`
BizSource string `json:"biz_source"`
BlindGift interface{} `json:"blind_gift"`
BroadcastId int `json:"broadcast_id"`
CoinType string `json:"coin_type"`
ComboResourcesId int `json:"combo_resources_id"`
ComboSend interface{} `json:"combo_send"`
ComboStayTime int `json:"combo_stay_time"`
ComboTotalCoin int `json:"combo_total_coin"`
CritProb int `json:"crit_prob"`
Demarcation int `json:"demarcation"`
DiscountPrice int `json:"discount_price"`
Dmscore int `json:"dmscore"`
Draw int `json:"draw"`
Effect int `json:"effect"`
EffectBlock int `json:"effect_block"`
Face string `json:"face"`
FloatScResourceId int `json:"float_sc_resource_id"`
GiftId int `json:"giftId"`
GiftName string `json:"giftName"`
GiftType int `json:"giftType"`
Gold int `json:"gold"`
GuardLevel int `json:"guard_level"`
IsFirst bool `json:"is_first"`
IsSpecialBatch int `json:"is_special_batch"`
Magnification float64 `json:"magnification"`
MedalInfo struct {
AnchorRoomid int `json:"anchor_roomid"`
AnchorUname string `json:"anchor_uname"`
GuardLevel int `json:"guard_level"`
IconId int `json:"icon_id"`
IsLighted int `json:"is_lighted"`
MedalColor int `json:"medal_color"`
MedalColorBorder int `json:"medal_color_border"`
MedalColorEnd int `json:"medal_color_end"`
MedalColorStart int `json:"medal_color_start"`
MedalLevel int `json:"medal_level"`
MedalName string `json:"medal_name"`
Special string `json:"special"`
TargetId int `json:"target_id"`
} `json:"medal_info"`
NameColor string `json:"name_color"`
Num int `json:"num"`
OriginalGiftName string `json:"original_gift_name"`
Price int `json:"price"`
Rcost int `json:"rcost"`
Remain int `json:"remain"`
Rnd string `json:"rnd"`
SendMaster interface{} `json:"send_master"`
Silver int `json:"silver"`
Super int `json:"super"`
SuperBatchGiftNum int `json:"super_batch_gift_num"`
SuperGiftNum int `json:"super_gift_num"`
SvgaBlock int `json:"svga_block"`
TagImage string `json:"tag_image"`
Tid string `json:"tid"`
Timestamp int `json:"timestamp"`
TopList interface{} `json:"top_list"`
TotalCoin int `json:"total_coin"`
Uid int `json:"uid"`
Uname string `json:"uname"`
}
type ComboSend struct {
Action string `json:"action"`
BatchComboId string `json:"batch_combo_id"`
BatchComboNum int `json:"batch_combo_num"`
ComboId string `json:"combo_id"`
ComboNum int `json:"combo_num"`
ComboTotalCoin int `json:"combo_total_coin"`
Dmscore int `json:"dmscore"`
GiftId int `json:"gift_id"`
GiftName string `json:"gift_name"`
GiftNum int `json:"gift_num"`
IsShow int `json:"is_show"`
MedalInfo struct {
AnchorRoomid int `json:"anchor_roomid"`
AnchorUname string `json:"anchor_uname"`
GuardLevel int `json:"guard_level"`
IconId int `json:"icon_id"`
IsLighted int `json:"is_lighted"`
MedalColor int `json:"medal_color"`
MedalColorBorder int `json:"medal_color_border"`
MedalColorEnd int `json:"medal_color_end"`
MedalColorStart int `json:"medal_color_start"`
MedalLevel int `json:"medal_level"`
MedalName string `json:"medal_name"`
Special string `json:"special"`
TargetId int `json:"target_id"`
} `json:"medal_info"`
NameColor string `json:"name_color"`
RUname string `json:"r_uname"`
Ruid int `json:"ruid"`
SendMaster interface{} `json:"send_master"`
TotalNum int `json:"total_num"`
Uid int `json:"uid"`
Uname string `json:"uname"`
}
func (g *Gift) Parse(data []byte) {
sb := utils.BytesToString(data)
sd := gjson.Get(sb, "data").String()
err := utils.UnmarshalStr(sd, g)
if err != nil {
log.Error("parse Gift failed")
}
}