From: qydysky Date: Sat, 12 Jun 2021 18:16:23 +0000 (+0800) Subject: lessdanmu fix X-Git-Tag: v0.5.10~41^2~103 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=b671ab9922dad2d484e25590e156ed3ebc6ab11a;p=bili_danmu%2F.git lessdanmu fix --- diff --git a/Reply/F.go b/Reply/F.go index 1dc8bb5..1cca6af 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -1657,8 +1657,6 @@ type Lessdanmu struct { limit *limit.Limit max_num int threshold float32 - - sync.RWMutex } var lessdanmu = Lessdanmu{ @@ -1666,51 +1664,19 @@ var lessdanmu = Lessdanmu{ } func init() { - if max_num,ok := c.K_v.LoadV(`每10秒显示弹幕数`).(float64);ok && int(max_num) >= 1 { - flog.Base_add(`更少弹幕`).L(`T: `,`每10秒弹幕数:`,int(max_num)) + if max_num,ok := c.K_v.LoadV(`每秒显示弹幕数`).(float64);ok && int(max_num) >= 1 { + flog.Base_add(`更少弹幕`).L(`T: `,`每秒弹幕数:`,int(max_num)) lessdanmu.max_num = int(max_num) - lessdanmu.limit = limit.New(int(max_num),10000,0) - go func(){ - //等待启动 - for lessdanmu.limit.PTK() == lessdanmu.max_num { - time.Sleep(time.Second*3) - } - - for { - time.Sleep(time.Second*10) - - lessdanmu.Lock() - if lessdanmu.roomid != c.Roomid { - lessdanmu.buf = nil - lessdanmu.roomid = c.Roomid - lessdanmu.threshold = 0.7 - flog.Base_add(`更少弹幕`).L(`T: `,`房间更新:`,lessdanmu.roomid) - lessdanmu.Unlock() - continue - } - if ptk := lessdanmu.limit.PTK();ptk == lessdanmu.max_num { - if lessdanmu.threshold > 0.03 { - lessdanmu.threshold -= 0.03 - } - } else if ptk == 0 { - if lessdanmu.threshold < 0.97 { - lessdanmu.threshold += 0.03 - } - } - lessdanmu.Unlock() - } - }() + lessdanmu.limit = limit.New(int(max_num),1000,0)//timeout right now } } func Lessdanmuf(s string) (show bool) { if !IsOn("相似弹幕忽略") {return true} if lessdanmu.roomid != c.Roomid { - lessdanmu.Lock() lessdanmu.buf = nil lessdanmu.roomid = c.Roomid lessdanmu.threshold = 0.7 - lessdanmu.Unlock() flog.Base_add(`更少弹幕`).L(`T: `,`房间更新:`,lessdanmu.roomid) return true } @@ -1725,12 +1691,10 @@ func Lessdanmuf(s string) (show bool) { Jiezouf(lessdanmu.buf) lessdanmu.buf = append(lessdanmu.buf[1:], s) - lessdanmu.RLock() show = o < lessdanmu.threshold - lessdanmu.RUnlock() if show && lessdanmu.max_num > 0 { - lessdanmu.limit.TO() + return !lessdanmu.limit.TO() } return } diff --git a/bili_danmu.go b/bili_danmu.go index 96e219e..a6f01b5 100644 --- a/bili_danmu.go +++ b/bili_danmu.go @@ -62,6 +62,11 @@ func Demo(roomid ...int) { if room == 0 && len(roomid) != 0 { room = roomid[0] } + + //如果连接中断,则等待 + F.KeepConnect() + //获取cookie + F.Get(`Cookie`) if room == 0 { c.Log.Block(1000)//等待所有日志输出完毕 fmt.Println("输入房间号或` live`获取正在直播的主播") @@ -72,12 +77,6 @@ func Demo(roomid ...int) { go func(){change_room_chan <- struct{}{}}() } } - - - //如果连接中断,则等待 - F.KeepConnect() - //获取cookie - F.Get(`Cookie`) //命令行操作 切换房间 发送弹幕 go F.Cmd() diff --git a/demo/config/config_K_v.json b/demo/config/config_K_v.json index 4fd5b1d..6c288f8 100644 --- a/demo/config/config_K_v.json +++ b/demo/config/config_K_v.json @@ -58,8 +58,8 @@ "弹幕处理": "", "弹幕合并": true, "相似弹幕忽略": true, - "每10秒显示弹幕数-help": "为0时禁用,相似弹幕忽略需设为true", - "每10秒显示弹幕数": 10, + "每秒显示弹幕数-help": "为0时禁用,相似弹幕忽略需设为true", + "每秒显示弹幕数": 1, "精简弹幕": true, "弹幕机": "", "反射弹幕机": true, diff --git a/demo/go.mod b/demo/go.mod index 66cf4e0..f10fd37 100644 --- a/demo/go.mod +++ b/demo/go.mod @@ -14,7 +14,7 @@ require ( github.com/miekg/dns v1.1.42 // indirect github.com/mitchellh/mapstructure v1.4.1 // indirect github.com/qydysky/bili_danmu v0.5.9 - github.com/qydysky/part v0.5.23 // indirect + github.com/qydysky/part v0.5.24 // indirect github.com/shirou/gopsutil v3.21.5+incompatible // indirect github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect diff --git a/demo/go.sum b/demo/go.sum index 1315ff5..41115e0 100644 --- a/demo/go.sum +++ b/demo/go.sum @@ -308,6 +308,8 @@ github.com/qydysky/part v0.5.22 h1:KPaREUPSHidO/W9Blp708BSi7oqOfOE467+Tid6x25U= github.com/qydysky/part v0.5.22/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg= github.com/qydysky/part v0.5.23 h1:JaP+t+ILHScJh7FPE6AUPqrkdMhfRIXSgAetJNPFTp0= github.com/qydysky/part v0.5.23/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg= +github.com/qydysky/part v0.5.24 h1:hnHI5SPpm6I61/q7s83D3NlHgIMHjsvukw6xAbZeanc= +github.com/qydysky/part v0.5.24/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg= github.com/qydysky/part/msgq v0.0.0-20201213031129-ca3253dc72ad h1:Jtzf509lQrkUMGTV0Sc6IDCAiR1VrBcHrIban7hpye4= github.com/qydysky/part/msgq v0.0.0-20201213031129-ca3253dc72ad/go.mod h1:w32TkJNVtTJd4LOS09cq+4uYG6itcN2vsqw+slp44Rg= github.com/qydysky/part/msgq v0.0.0-20201213120821-f36e49c32bba h1:1ew9dRpc0Rux0WkWeT/4AE15ynYWmL2D7onJEJIFOB8= diff --git a/go.mod b/go.mod index a737b5f..4816e42 100644 --- a/go.mod +++ b/go.mod @@ -12,13 +12,13 @@ require ( github.com/mdp/qrterminal/v3 v3.0.0 github.com/miekg/dns v1.1.42 // indirect github.com/mitchellh/mapstructure v1.4.1 // indirect - github.com/qydysky/part v0.5.23 + github.com/qydysky/part v0.5.24 github.com/shirou/gopsutil v3.21.5+incompatible // indirect github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 github.com/tklauser/go-sysconf v0.3.6 // indirect golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect - golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect - golang.org/x/sys v0.0.0-20210608053332-aa57babbf139 // indirect + golang.org/x/net v0.0.0-20210610132358-84b48f89b13b // indirect + golang.org/x/sys v0.0.0-20210611083646-a4fc73990273 // indirect golang.org/x/text v0.3.6 ) diff --git a/go.sum b/go.sum index 86e4191..5ac7a6f 100644 --- a/go.sum +++ b/go.sum @@ -82,6 +82,8 @@ github.com/qydysky/part v0.5.22 h1:KPaREUPSHidO/W9Blp708BSi7oqOfOE467+Tid6x25U= github.com/qydysky/part v0.5.22/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg= github.com/qydysky/part v0.5.23 h1:JaP+t+ILHScJh7FPE6AUPqrkdMhfRIXSgAetJNPFTp0= github.com/qydysky/part v0.5.23/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg= +github.com/qydysky/part v0.5.24 h1:hnHI5SPpm6I61/q7s83D3NlHgIMHjsvukw6xAbZeanc= +github.com/qydysky/part v0.5.24/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg= github.com/qydysky/part/msgq v0.0.0-20201213120821-f36e49c32bba h1:1ew9dRpc0Rux0WkWeT/4AE15ynYWmL2D7onJEJIFOB8= github.com/qydysky/part/msgq v0.0.0-20201213120821-f36e49c32bba/go.mod h1:w32TkJNVtTJd4LOS09cq+4uYG6itcN2vsqw+slp44Rg= github.com/shirou/gopsutil v2.20.7+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= @@ -133,6 +135,8 @@ golang.org/x/net v0.0.0-20210510120150-4163338589ed h1:p9UgmWI9wKpfYmgaV/IZKGdXc golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -165,6 +169,8 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7q golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210608053332-aa57babbf139 h1:C+AwYEtBp/VQwoLntUmQ/yx3MS9vmZaKNdw5eOpoQe8= golang.org/x/sys v0.0.0-20210608053332-aa57babbf139/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210611083646-a4fc73990273 h1:faDu4veV+8pcThn4fewv6TVlNCezafGoC1gM/mxQLbQ= +golang.org/x/sys v0.0.0-20210611083646-a4fc73990273/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=