From d97433152139953a6240adb5dcb3f0ec4b9be354 Mon Sep 17 00:00:00 2001 From: qydysky Date: Mon, 31 May 2021 23:04:03 +0800 Subject: [PATCH] =?utf8?q?=E5=BC=B9=E5=B9=95=E6=97=B6=E9=97=B4=E6=88=B3?= =?utf8?q?=E5=81=8F=E7=A6=BB=E8=BF=87=E5=A4=A7=E9=87=8D=E6=96=B0=E8=BF=9E?= =?utf8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/Reply.go | 60 ++++++++++++++++++++++++++++++-------------------- bili_danmu.go | 23 +++++++++++++++++-- 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/Reply/Reply.go b/Reply/Reply.go index cb08b67..ee3ada9 100644 --- a/Reply/Reply.go +++ b/Reply/Reply.go @@ -11,6 +11,7 @@ import ( p "github.com/qydysky/part" mq "github.com/qydysky/part/msgq" + limit "github.com/qydysky/part/limit" F "github.com/qydysky/bili_danmu/F" ws_msg "github.com/qydysky/bili_danmu/Reply/ws_msg" send "github.com/qydysky/bili_danmu/Send" @@ -783,33 +784,44 @@ func (replyF) roominfo(s string){ } //Msg-弹幕处理 +var flash_limit = limit.New(1, 10000, -1)//-1 马上超时 func (replyF) danmu(s string) { - if info := p.Json().GetValFromS(s, "info");info == nil { - msglog.L(`E: `, "info", info) - return - } else { - infob := info.([]interface{}) - msg := infob[1].(string) - auth := infob[2].([]interface{})[1] - uid := strconv.Itoa(int(infob[2].([]interface{})[0].(float64))) - - msglog := msglog.Log_show_control(false) - - {//附加功能 弹幕机 封禁 弹幕合并 - Danmujif(msg) - if Autobanf(msg) { - Gui_show(Itos([]interface{}{"风险", auth, ":", msg})) - fmt.Println("风险", auth, ":", msg) - msglog.Base_add("风险").L(`I: `, auth, ":", msg) - return - } - if i := Autoskipf(msg); i > 0 { - msglog.L(`I: `, auth, ":", msg) - return - } + var j struct { + Cmd string `json:"cmd"` + Info []interface{} `json:"info"` + } + + if e := json.Unmarshal([]byte(s), &j);e != nil { + msglog.L(`E: `, e) + } + + infob := j.Info + msg := infob[1].(string) + auth := infob[2].([]interface{})[1] + uid := strconv.Itoa(int(infob[2].([]interface{})[0].(float64))) + timeStramp := int64(infob[0].([]interface{})[4].(float64)) + if t := p.Sys().GetMTime() - timeStramp; t > 60*1000 { + if flash_limit.TO() {return} + msglog.L(`W: `, `重进,弹幕时间戳偏离`, t, `ms`) + c.Danmu_Main_mq.Push_tag(`flash_room`,nil) + } + + msglog := msglog.Log_show_control(false) + + {//附加功能 弹幕机 封禁 弹幕合并 + Danmujif(msg) + if Autobanf(msg) { + Gui_show(Itos([]interface{}{"风险", auth, ":", msg})) + fmt.Println("风险", auth, ":", msg) + msglog.Base_add("风险").L(`I: `, auth, ":", msg) + return + } + if i := Autoskipf(msg); i > 0 { + msglog.L(`I: `, auth, ":", msg) + return } - Msg_showdanmu(auth, msg, uid) } + Msg_showdanmu(auth, msg, uid) } //弹幕发送 diff --git a/bili_danmu.go b/bili_danmu.go index 7b8cae8..736346a 100644 --- a/bili_danmu.go +++ b/bili_danmu.go @@ -52,7 +52,10 @@ func Demo(roomid ...int) { var groomid = flag.Int("r", 0, "roomid") flag.Parse() - var change_room_chan = make(chan struct{}) + var ( + change_room_chan = make(chan struct{}) + flash_room_chan = make(chan struct{}) + ) go func(){ var room = *groomid @@ -78,6 +81,13 @@ func Demo(roomid ...int) { //使用带tag的消息队列在功能间传递消息 c.Danmu_Main_mq.Pull_tag(msgq.FuncMap{ + `flash_room`:func(data interface{})(bool){//房间重进 + select { + case flash_room_chan <- struct{}{}:; + default:; + } + return false + }, `change_room`:func(data interface{})(bool){//房间改变 c.Rev = 0.0 //营收 c.Renqi = 1//人气置1 @@ -167,7 +177,8 @@ func Demo(roomid ...int) { //对每个弹幕服务器尝试 F.Get(`WSURL`) - for _, v := range c.WSURL { + for i:=0;i