]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Improve 弹幕分值默认统计弹幕数 (#162)
authorqydysky <qydysky@foxmail.com>
Thu, 6 Feb 2025 17:04:45 +0000 (01:04 +0800)
committerGitHub <noreply@github.com>
Thu, 6 Feb 2025 17:04:45 +0000 (01:04 +0800)
Reply/F/danmuCountPerMin/danmuCountPerMin.go
Reply/stream.go
demo/config/config_K_v.json

index b0a1830a09d80d6774afa1ac50555b2bbf5c0d81..2b7cfc5c950a9f30acab156ee017664156dabf5f 100644 (file)
@@ -72,6 +72,14 @@ func (t *danmuCountPerMin) Rec(ctx context.Context, rid int, savePath string) fu
                cfgMsg := make(map[*regexp.Regexp]int)
                cfgUid := make(map[string]int)
 
+               if cfg == nil { // 默认统计弹幕数
+                       cfg = map[string]any{
+                               `danmu`: map[string]any{
+                                       `.`: 1.0,
+                               },
+                       }
+               }
+
                if m, ok := cfg["danmu"].(map[string]any); ok {
                        for k, v := range m {
                                if point, ok := v.(float64); ok && point != 0 {
index 57932125e81db2bfd1a842a33ed238ea471e8a21..5c75d92230cb0cf55857785cf6f7e5318de213c3 100644 (file)
@@ -1406,9 +1406,7 @@ func (t *M4SStream) Start() bool {
                                        startf := func(_ *M4SStream) error {
                                                l.L(`T: `, `开始`)
                                                //弹幕分值统计
-                                               if m, ok := ms.common.K_v.LoadV("弹幕分值").(map[string]any); ok {
-                                                       replyFunc.DanmuCountPerMin.Rec(contextC, ms.common.Roomid, ms.GetSavePath())(m)
-                                               }
+                                               replyFunc.DanmuCountPerMin.Rec(contextC, ms.common.Roomid, ms.GetSavePath())(ms.common.K_v.LoadV("弹幕分值").(map[string]any))
                                                return nil
                                        }
                                        stopf := func(_ *M4SStream) error {
index 95951401f704017947625d2c57f904b50b8dd633..04ea2984395ede64081234968c8191f2cfdfd2c8 100644 (file)
             "env": ""
         }
     ],
-    "弹幕分值-help":"对每条弹幕进行评分,每分钟输出分值到danmuCountPerMin.json,无有效规则时不生成json,用于后续评估",
+    "弹幕分值-help":"对每条弹幕进行评分,每分钟输出分值到danmuCountPerMin.json,无有效规则时默认统计弹幕数,用于后续评估",
     "弹幕分值":{
         "danmu-help":"key为正则表达式,匹配成功时分值加value,value为0时忽略",
         "danmu": {