]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
lessdanmu fix
authorqydysky <qydysky@foxmail.com>
Sat, 12 Jun 2021 18:16:23 +0000 (02:16 +0800)
committerqydysky <qydysky@foxmail.com>
Sat, 12 Jun 2021 18:16:23 +0000 (02:16 +0800)
Reply/F.go
bili_danmu.go
demo/config/config_K_v.json
demo/go.mod
demo/go.sum
go.mod
go.sum

index 1dc8bb59bf37db36de4d823e936f768038f93369..1cca6affde0b9348f235108875e970c0eed7f81a 100644 (file)
@@ -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
 }
index 96e219ee2141619b3f55db3a1d39c07cb238329b..a6f01b52c3c25fc88006638eec4608da081f528f 100644 (file)
@@ -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()
 
index 4fd5b1d5f9946349d8dba8d452795029c7f44b5c..6c288f8a3b8afdef3c057f5e46e2caeaeaea763a 100644 (file)
@@ -58,8 +58,8 @@
     "弹幕处理": "",
     "弹幕合并": true,
     "相似弹幕忽略": true,
-    "每10秒显示弹幕数-help": "为0时禁用,相似弹幕忽略需设为true",
-    "每10秒显示弹幕数": 10,
+    "每秒显示弹幕数-help": "为0时禁用,相似弹幕忽略需设为true",
+    "每秒显示弹幕数": 1,
     "精简弹幕": true,
     "弹幕机": "",
     "反射弹幕机": true,
index 66cf4e0f771b8e4923e0d83297086777d2cde20f..f10fd377468deecc67d241750994400d4bdce838 100644 (file)
@@ -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
index 1315ff5404a3ee7aa00d45fa958bfff47841ff10..41115e06883f1c45360574a68a85979326946123 100644 (file)
@@ -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 a737b5fed790664db909a5b763444705f542e606..4816e4227b3b7988daba8682aee76f505077526a 100644 (file)
--- 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 86e41919bd23373edfcec97f2ed19e88fd489e7f..5ac7a6fbb5f537e42020598fce594848f2b0472a 100644 (file)
--- 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=