From 299de5bf7dbe4b892c1dd1386e1eb069a43cc808 Mon Sep 17 00:00:00 2001 From: qydysky Date: Fri, 7 Feb 2025 01:04:45 +0800 Subject: [PATCH] =?utf8?q?Improve=20=E5=BC=B9=E5=B9=95=E5=88=86=E5=80=BC?= =?utf8?q?=E9=BB=98=E8=AE=A4=E7=BB=9F=E8=AE=A1=E5=BC=B9=E5=B9=95=E6=95=B0?= =?utf8?q?=20(#162)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/F/danmuCountPerMin/danmuCountPerMin.go | 8 ++++++++ Reply/stream.go | 4 +--- demo/config/config_K_v.json | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Reply/F/danmuCountPerMin/danmuCountPerMin.go b/Reply/F/danmuCountPerMin/danmuCountPerMin.go index b0a1830..2b7cfc5 100644 --- a/Reply/F/danmuCountPerMin/danmuCountPerMin.go +++ b/Reply/F/danmuCountPerMin/danmuCountPerMin.go @@ -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 { diff --git a/Reply/stream.go b/Reply/stream.go index 5793212..5c75d92 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -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 { diff --git a/demo/config/config_K_v.json b/demo/config/config_K_v.json index 9595140..04ea298 100644 --- a/demo/config/config_K_v.json +++ b/demo/config/config_K_v.json @@ -234,7 +234,7 @@ "env": "" } ], - "弹幕分值-help":"对每条弹幕进行评分,每分钟输出分值到danmuCountPerMin.json,无有效规则时不生成json,用于后续评估", + "弹幕分值-help":"对每条弹幕进行评分,每分钟输出分值到danmuCountPerMin.json,无有效规则时默认统计弹幕数,用于后续评估", "弹幕分值":{ "danmu-help":"key为正则表达式,匹配成功时分值加value,value为0时忽略", "danmu": { -- 2.39.2