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)
dmMsg := &pbMq.MqDanmaku{
Platform: "bilibili",
Platform: pbMq.Platform_name[int32(pbMq.Platform_bilibili)],
LiveRoomId: d.liveRoomId,
Uid: dm.UID,
Uname: dm.Uname,

@ -17,7 +17,7 @@ type SendGift struct {
BizSource string `json:"biz_source"` // ?? :live
BlindGift interface{} `json:"blind_gift"` // ??
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"` // ???
ComboSend interface{} `json:"combo_send"` // ???
ComboStayTime int `json:"combo_stay_time"` // 连击停留时间??? 秒?
@ -25,15 +25,15 @@ type SendGift struct {
CritProb int `json:"crit_prob"` // ???
Demarcation int `json:"demarcation"` // ???: 1
DiscountPrice int `json:"discount_price"` // 折扣价???
DMScore int `json:"dmscore"` /// ???
DMScore int `json:"dmscore"` // 活动积分普通道具为0
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"` // 金币?
GiftType int `json:"giftType"` // 礼物类型 普通,弹幕,活动
Gold int `json:"gold"` // 用户剩余金瓜子
GuardLevel int `json:"guard_level"` // 舰队等级
IsFirst bool `json:"is_first"` // 是否首次投喂?
IsSpecialBatch int `json:"is_special_batch"` // ???
@ -44,10 +44,10 @@ type SendGift struct {
OriginalGiftName string `json:"original_gift_name"` // 原始礼物名称???
Price int `json:"price"` // 价格? 但不是电池
RCost int `json:"rcost"` // ???
Remain int `json:"remain"` // 剩余?
Remain int `json:"remain"` // 用户道具包裹剩余数量
Rnd string `json:"rnd"` // 随机数?
SendMaster interface{} `json:"send_master"` // ???
Silver int `json:"silver"` // ???
Silver int `json:"silver"` // 用户剩余银瓜子
Super int `json:"super"` // ???
SuperBatchGiftNum int `json:"super_batch_gift_num"` // ???
SuperGiftNum int `json:"super_gift_num"` // ???
@ -55,7 +55,7 @@ type SendGift struct {
TagImage string `json:"tag_image"` // ???
Timestamp int `json:"timestamp"` // 赠送时间
TopList interface{} `json:"top_list"` // ???
TotalCoin int `json:"total_coin"` // ???
TotalCoin int `json:"total_coin"` // 总值 瓜子数
Uid int `json:"uid"` // 用户ID
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)
dmMsg := &pbMq.MqGift{
Platform: "bilibili",
Platform: pbMq.Platform_name[int32(pbMq.Platform_bilibili)],
LiveRoomId: h.liveRoomId,
Uid: int64(baseMsg.Data.Uid),
Uname: baseMsg.Data.Uname,

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

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

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

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc-gen-go v1.28.0
// protoc v3.19.4
// source: mq.proto
@ -20,6 +20,58 @@ const (
_ = 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 {
state protoimpl.MessageState
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,
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, 0x42, 0x07, 0x5a, 0x05, 0x2f, 0x70, 0x62, 0x4d, 0x71, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
0x69, 0x6d, 0x65, 0x2a, 0x39, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12,
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 (
@ -254,10 +309,12 @@ func file_mq_proto_rawDescGZIP() []byte {
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_goTypes = []interface{}{
(*MqDanmaku)(nil), // 0: pb.MqDanmaku
(*MqGift)(nil), // 1: pb.MqGift
(Platform)(0), // 0: pb.Platform
(*MqDanmaku)(nil), // 1: pb.MqDanmaku
(*MqGift)(nil), // 2: pb.MqGift
}
var file_mq_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
@ -303,13 +360,14 @@ func file_mq_proto_init() {
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_mq_proto_rawDesc,
NumEnums: 0,
NumEnums: 1,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_mq_proto_goTypes,
DependencyIndexes: file_mq_proto_depIdxs,
EnumInfos: file_mq_proto_enumTypes,
MessageInfos: file_mq_proto_msgTypes,
}.Build()
File_mq_proto = out.File

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

Loading…
Cancel
Save