feat: 更新协议,添加平台枚举;更新配置,添加监听开关。

main
NorthLan 3 years ago
parent d64828860d
commit c17423c37b

@ -114,7 +114,7 @@ func (d *DanmakuHandler) HandlerMessage(data []byte) {
logger.SLog.Debugf("%s 说: %s", dm.Uname, dm.Content) logger.SLog.Debugf("%s 说: %s", dm.Uname, dm.Content)
dmMsg := &pbMq.MqDanmaku{ dmMsg := &pbMq.MqDanmaku{
Platform: "bilibili", Platform: pbMq.Platform_name[int32(pbMq.Platform_bilibili)],
LiveRoomId: d.liveRoomId, LiveRoomId: d.liveRoomId,
Uid: dm.UID, Uid: dm.UID,
Uname: dm.Uname, Uname: dm.Uname,

@ -17,7 +17,7 @@ type SendGift struct {
BizSource string `json:"biz_source"` // ?? :live BizSource string `json:"biz_source"` // ?? :live
BlindGift interface{} `json:"blind_gift"` // ?? BlindGift interface{} `json:"blind_gift"` // ??
BroadcastId int `json:"broadcast_id"` // 广播ID ?? BroadcastId int `json:"broadcast_id"` // 广播ID ??
CoinType string `json:"coin_type"` // 币类型??? :silver CoinType string `json:"coin_type"` // 瓜子类型, gold金瓜子 silver银瓜子(免费礼物)
ComboResourcesId int `json:"combo_resources_id"` // ??? ComboResourcesId int `json:"combo_resources_id"` // ???
ComboSend interface{} `json:"combo_send"` // ??? ComboSend interface{} `json:"combo_send"` // ???
ComboStayTime int `json:"combo_stay_time"` // 连击停留时间??? 秒? ComboStayTime int `json:"combo_stay_time"` // 连击停留时间??? 秒?
@ -25,15 +25,15 @@ type SendGift struct {
CritProb int `json:"crit_prob"` // ??? CritProb int `json:"crit_prob"` // ???
Demarcation int `json:"demarcation"` // ???: 1 Demarcation int `json:"demarcation"` // ???: 1
DiscountPrice int `json:"discount_price"` // 折扣价??? DiscountPrice int `json:"discount_price"` // 折扣价???
DMScore int `json:"dmscore"` /// ??? DMScore int `json:"dmscore"` // 活动积分普通道具为0
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"` // 头像?
GiftId int `json:"giftId"` // 礼物ID 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"` // ???
@ -44,10 +44,10 @@ type SendGift struct {
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"` // ???
@ -55,7 +55,7 @@ type SendGift struct {
TagImage string `json:"tag_image"` // ??? TagImage string `json:"tag_image"` // ???
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"` // 用户ID Uid int `json:"uid"` // 用户ID
Uname string `json:"uname"` // 用户名 Uname string `json:"uname"` // 用户名
} }
@ -89,7 +89,7 @@ func (h *SendGiftHandler) HandlerMessage(data []byte) {
//logger.SLog.Infof("%s %s礼物 %s x%d", baseMsg.Data.Uname, baseMsg.Data.Action, baseMsg.Data.GiftName, baseMsg.Data.Num) //logger.SLog.Infof("%s %s礼物 %s x%d", baseMsg.Data.Uname, baseMsg.Data.Action, baseMsg.Data.GiftName, baseMsg.Data.Num)
dmMsg := &pbMq.MqGift{ dmMsg := &pbMq.MqGift{
Platform: "bilibili", Platform: pbMq.Platform_name[int32(pbMq.Platform_bilibili)],
LiveRoomId: h.liveRoomId, LiveRoomId: h.liveRoomId,
Uid: int64(baseMsg.Data.Uid), Uid: int64(baseMsg.Data.Uid),
Uname: baseMsg.Data.Uname, Uname: baseMsg.Data.Uname,

@ -1,9 +1,10 @@
Bilibili: Bilibili:
Enabled: true
Url: wss://broadcastlv.chat.bilibili.com:2245/sub Url: wss://broadcastlv.chat.bilibili.com:2245/sub
GetRoomUrl: https://api.live.bilibili.com/room/v1/Room/room_init?id= GetRoomUrl: https://api.live.bilibili.com/room/v1/Room/room_init?id=
HeartbeatInterval: 30 HeartbeatInterval: 30
UserId: 111222 UserId: 111222
RoomId: 7777 RoomId: 8722013
Log: Log:
Console: Console:
Level: info Level: info

@ -17,6 +17,7 @@ type (
} }
config struct { config struct {
Bilibili struct { Bilibili struct {
Enabled bool // 是否启用
Url string // 弹幕服务器url Url string // 弹幕服务器url
GetRoomUrl string // 获取房间信息url GetRoomUrl string // 获取房间信息url
RoomId int64 // 待连接roomId RoomId int64 // 待连接roomId

@ -20,14 +20,15 @@ func main() {
var wg sync.WaitGroup var wg sync.WaitGroup
bLive := bilibili.NewLiveBilibili() if config.Config.Bilibili.Enabled {
wg.Add(1) wg.Add(1)
go func() { bLive := bilibili.NewLiveBilibili()
if err := bLive.Serve(); err != nil { go func() {
wg.Done() if err := bLive.Serve(); err != nil {
panic(err) wg.Done()
} panic(err)
}() }
}()
}
wg.Wait() wg.Wait()
} }

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.27.1 // protoc-gen-go v1.28.0
// protoc v3.19.4 // protoc v3.19.4
// source: mq.proto // source: mq.proto
@ -20,6 +20,58 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
type Platform int32
const (
Platform_bilibili Platform = 0 // B站
Platform_huya Platform = 1 // 虎牙
Platform_douyu Platform = 2 // 斗鱼
Platform_douyin Platform = 3 // 抖音
)
// Enum value maps for Platform.
var (
Platform_name = map[int32]string{
0: "bilibili",
1: "huya",
2: "douyu",
3: "douyin",
}
Platform_value = map[string]int32{
"bilibili": 0,
"huya": 1,
"douyu": 2,
"douyin": 3,
}
)
func (x Platform) Enum() *Platform {
p := new(Platform)
*p = x
return p
}
func (x Platform) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Platform) Descriptor() protoreflect.EnumDescriptor {
return file_mq_proto_enumTypes[0].Descriptor()
}
func (Platform) Type() protoreflect.EnumType {
return &file_mq_proto_enumTypes[0]
}
func (x Platform) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Platform.Descriptor instead.
func (Platform) EnumDescriptor() ([]byte, []int) {
return file_mq_proto_rawDescGZIP(), []int{0}
}
type MqDanmaku struct { type MqDanmaku struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -238,8 +290,11 @@ var file_mq_proto_rawDesc = []byte{
0x61, 0x6c, 0x43, 0x6f, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x6f, 0x61, 0x6c, 0x43, 0x6f, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x6f,
0x74, 0x61, 0x6c, 0x43, 0x6f, 0x69, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x6e, 0x64, 0x54, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x69, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x6e, 0x64, 0x54,
0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x6e, 0x64, 0x54,
0x69, 0x6d, 0x65, 0x42, 0x07, 0x5a, 0x05, 0x2f, 0x70, 0x62, 0x4d, 0x71, 0x62, 0x06, 0x70, 0x72, 0x69, 0x6d, 0x65, 0x2a, 0x39, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12,
0x6f, 0x74, 0x6f, 0x33, 0x0c, 0x0a, 0x08, 0x62, 0x69, 0x6c, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x10, 0x00, 0x12, 0x08, 0x0a,
0x04, 0x68, 0x75, 0x79, 0x61, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x64, 0x6f, 0x75, 0x79, 0x75,
0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x10, 0x03, 0x42, 0x07,
0x5a, 0x05, 0x2f, 0x70, 0x62, 0x4d, 0x71, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -254,10 +309,12 @@ func file_mq_proto_rawDescGZIP() []byte {
return file_mq_proto_rawDescData return file_mq_proto_rawDescData
} }
var file_mq_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_mq_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_mq_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_mq_proto_goTypes = []interface{}{ var file_mq_proto_goTypes = []interface{}{
(*MqDanmaku)(nil), // 0: pb.MqDanmaku (Platform)(0), // 0: pb.Platform
(*MqGift)(nil), // 1: pb.MqGift (*MqDanmaku)(nil), // 1: pb.MqDanmaku
(*MqGift)(nil), // 2: pb.MqGift
} }
var file_mq_proto_depIdxs = []int32{ var file_mq_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method output_type
@ -303,13 +360,14 @@ func file_mq_proto_init() {
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_mq_proto_rawDesc, RawDescriptor: file_mq_proto_rawDesc,
NumEnums: 0, NumEnums: 1,
NumMessages: 2, NumMessages: 2,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },
GoTypes: file_mq_proto_goTypes, GoTypes: file_mq_proto_goTypes,
DependencyIndexes: file_mq_proto_depIdxs, DependencyIndexes: file_mq_proto_depIdxs,
EnumInfos: file_mq_proto_enumTypes,
MessageInfos: file_mq_proto_msgTypes, MessageInfos: file_mq_proto_msgTypes,
}.Build() }.Build()
File_mq_proto = out.File File_mq_proto = out.File

@ -4,6 +4,13 @@ package pb;
option go_package = "/pbMq"; option go_package = "/pbMq";
enum Platform {
bilibili = 0; // B
huya = 1; //
douyu = 2; //
douyin = 3; //
}
message MqDanmaku { message MqDanmaku {
string platform = 1; string platform = 1;
int64 liveRoomId = 2; int64 liveRoomId = 2;

Loading…
Cancel
Save