You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
4.0 KiB
Go
76 lines
4.0 KiB
Go
3 years ago
|
package msg_handler
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
type SendGift struct {
|
||
|
Action string `json:"action"` // 动作,投喂等
|
||
|
BatchComboId string `json:"batch_combo_id"` // 礼物连击ID
|
||
|
BatchComboSend interface{} `json:"batch_combo_send"` // ???
|
||
|
BeatId string `json:"beatId"` // ???
|
||
|
BizSource string `json:"biz_source"` // ?? :live
|
||
|
BlindGift interface{} `json:"blind_gift"` // ??
|
||
|
BroadcastId int `json:"broadcast_id"` // 广播ID ??
|
||
|
CoinType string `json:"coin_type"` // 币类型??? :silver
|
||
|
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"` // ???: 1
|
||
|
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"` // 头像?
|
||
|
GiftId int `json:"giftId"` // 礼物ID
|
||
|
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 int `json:"magnification"` // 是否放大???
|
||
|
MedalInfo *FansMedal `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"` // ???
|
||
|
Timestamp int `json:"timestamp"` // 赠送时间
|
||
|
TopList interface{} `json:"top_list"` // ???
|
||
|
TotalCoin int `json:"total_coin"` // ???
|
||
|
Uid int `json:"uid"` // 用户ID
|
||
|
Uname string `json:"uname"` // 用户名
|
||
|
}
|
||
|
|
||
|
type SendGiftHandler struct {
|
||
|
}
|
||
|
|
||
|
func (h *SendGiftHandler) CMD() string {
|
||
|
return "SEND_GIFT"
|
||
|
}
|
||
|
|
||
|
func (h *SendGiftHandler) HandlerMessage(data []byte) {
|
||
|
var baseMsg struct {
|
||
|
CMD string `json:"cmd"`
|
||
|
Data *SendGift `json:"data"`
|
||
|
}
|
||
|
if err := json.Unmarshal(data, &baseMsg); err != nil {
|
||
|
return
|
||
|
}
|
||
|
fmt.Printf("%s %s礼物 %s x%d\n", baseMsg.Data.Uname, baseMsg.Data.Action, baseMsg.Data.GiftName, baseMsg.Data.Num)
|
||
|
}
|