From: qydysky Date: Thu, 22 Jun 2023 14:57:01 +0000 (+0000) Subject: Add 弹幕输出到日志 X-Git-Tag: v0.9.15~2 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=bf93fffcbe607c7222175824b7bae3fc7d307c43;p=bili_danmu%2F.git Add 弹幕输出到日志 --- diff --git a/CV/Var.go b/CV/Var.go index 3a28939..3d86729 100644 --- a/CV/Var.go +++ b/CV/Var.go @@ -433,7 +433,7 @@ func (t *Common) Init() *Common { url, urlok := v["url"].(string) create, createok := v["create"].(string) insert, insertok := v["insert"].(string) - if dbnameok && urlok && insertok { + if dbnameok && urlok && insertok && dbname != "" && url != "" && insert != "" { db, e := sql.Open(dbname, url) if e != nil { panic("保存日志至db打开连接错误" + e.Error()) diff --git a/Reply/Reply.go b/Reply/Reply.go index c1fd27b..42d9d16 100644 --- a/Reply/Reply.go +++ b/Reply/Reply.go @@ -1076,6 +1076,7 @@ func (replyF) danmu(s string) { } if len(infob) > 0 { item.msg, _ = infob[1].(string) + item.msg = strings.TrimSpace(item.msg) } if len(infob) > 1 { i, _ := infob[2].([]interface{}) @@ -1089,7 +1090,11 @@ func (replyF) danmu(s string) { item.roomid = c.C.Roomid } - msglog := msglog.Log_show_control(false) + danmulog := msglog.Base("å¼¹").LShow(false) + + if v, ok := c.C.K_v.LoadV(`弹幕输出到日志`).(bool); !ok || !v { + danmulog.LFile("") + } { // 附加功能 弹幕机 封禁 弹幕合并 // 保存弹幕至db @@ -1098,29 +1103,61 @@ func (replyF) danmu(s string) { // 对指定弹幕重新录制 danmuReLiveTriger.Init(c.C) danmuReLiveTriger.Check(item.uid, item.msg) - go Danmujif(item.msg) - // if Autobanf(item.msg) { - // Gui_show(Itos([]interface{}{"风险", item.auth, ":", item.msg})) - // fmt.Println("风险", item.auth, ":", item.msg) - // msglog.Base_add("风险").L(`I: `, item.auth, ":", item.msg) - // return - // } + // 语言tts 私信 + { + if item.uid != "" { + if item.auth != nil { + if s, ok := TTS_setting_string[item.uid]; ok && s != "" { + c.C.Danmu_Main_mq.Push_tag(`tts`, Danmu_mq_t{ //传入消息队列 + uid: item.uid, + m: map[string]string{ + `{auth}`: fmt.Sprint(item.auth), + `{msg}`: item.msg, + }, + }) + } + } + if i, e := strconv.Atoi(item.uid); e == nil { + if msg := c.C.K_v.LoadV(`弹幕私信`).(string); msg != "" { + c.C.Danmu_Main_mq.Push_tag(`pm`, send.Pm_item{ + Uid: i, + Msg: msg, + }) //弹幕私信 + } + } + if c.C.K_v.LoadV(`额外私信对象`).(float64) != 0 { + if msg, uid := c.C.K_v.LoadV(`弹幕私信(额外)`).(string), c.C.K_v.LoadV(`额外私信对象`).(float64); uid != 0 && msg != "" { + c.C.Danmu_Main_mq.Push_tag(`pm`, send.Pm_item{ + Uid: int(uid), + Msg: msg, + }) //弹幕私信-对额外 + } + } + } + } + // 反射弹幕机 + if IsOn("反射弹幕机") { + go Danmujif(item.msg) + } if i := Autoskipf(item.msg); i > 0 { - msglog.L(`I: `, item.auth, ":", item.msg) + danmulog.L(`I: `, item.auth, ":", item.msg) return } //附加功能 更少弹幕 if !Lessdanmuf(item.msg) { - msglog.L(`I: `, item.auth, ":", item.msg) + danmulog.L(`I: `, item.auth, ":", item.msg) return } if _msg := Shortdanmuf(item.msg); _msg == "" { - msglog.L(`I: `, item.auth, ":", item.msg) + danmulog.L(`I: `, item.auth, ":", item.msg) return } else { item.msg = _msg } } + if item.auth != nil { + danmulog.L(`I: `, item.auth, ":", item.msg) + } Msg_showdanmu(item) } @@ -1142,60 +1179,24 @@ func Msg_senddanmu(msg string) { // 弹幕显示 // 由于额外功能有些需要显示,为了统一管理,使用此方法进行处理 func Msg_showdanmu(item Danmu_item) { - msg := strings.TrimSpace(item.msg) - msglog := msglog.Log_show_control(false) - //room change if item.roomid != 0 && item.roomid != c.C.Roomid { return } - //展示 { //ass - Assf(msg) + Assf(item.msg) //直播流服务弹幕 SendStreamWs(item) if item.auth != nil { - Gui_show(fmt.Sprint(item.auth)+`: `+msg, item.uid) + Gui_show(fmt.Sprint(item.auth)+`: `+item.msg, item.uid) } else { - Gui_show(msg, item.uid) + Gui_show(item.msg, item.uid) } } - { //语言tts 私信 - if item.uid != "" { - if item.auth != nil { - c.C.Danmu_Main_mq.Push_tag(`tts`, Danmu_mq_t{ //传入消息队列 - uid: item.uid, - m: map[string]string{ - `{auth}`: fmt.Sprint(item.auth), - `{msg}`: msg, - }, - }) - } - if i, e := strconv.Atoi(item.uid); e == nil { - if msg := c.C.K_v.LoadV(`弹幕私信`).(string); msg != "" { - c.C.Danmu_Main_mq.Push_tag(`pm`, send.Pm_item{ - Uid: i, - Msg: msg, - }) //上舰私信 - } - } - if c.C.K_v.LoadV(`额外私信对象`).(float64) != 0 { - if msg, uid := c.C.K_v.LoadV(`上舰私信(额外)`).(string), c.C.K_v.LoadV(`额外私信对象`).(float64); uid != 0 && msg != "" { - c.C.Danmu_Main_mq.Push_tag(`pm`, send.Pm_item{ - Uid: int(uid), - Msg: msg, - }) //上舰私信-对额外 - } - } - } - } - fmt.Println(msg) - if item.auth != nil { - msglog.L(`I: `, item.auth, ":", msg) - } + fmt.Println(item.msg) } type Danmu_mq_t struct { diff --git a/Reply/tts.go b/Reply/tts.go index a31ae47..a163a32 100644 --- a/Reply/tts.go +++ b/Reply/tts.go @@ -28,7 +28,7 @@ import ( ) var ( - tts_setting_string = map[string]string{ + TTS_setting_string = map[string]string{ "0buyguide": "感谢{D}", "0gift": "感谢{D}", "0superchat": "感谢{D}", @@ -91,7 +91,7 @@ func init() { _ = json.Unmarshal(bb, &buf) if onoff, ok := buf[`onoff`]; ok { for k, v := range onoff.(map[string]interface{}) { - tts_setting_string[k] = v.(string) + TTS_setting_string[k] = v.(string) } } if replace, ok := buf[`replace`]; ok { @@ -118,7 +118,7 @@ func init() { c.C.Danmu_Main_mq.Pull_tag(msgq.FuncMap{ `tts`: func(data interface{}) bool { //tts d, _ := data.(Danmu_mq_t) - if s, ok := tts_setting_string[d.uid]; ok && len(d.m) != 0 && s != "" { + if s, ok := TTS_setting_string[d.uid]; ok && len(d.m) != 0 && s != "" { for k, v := range d.m { s = strings.ReplaceAll(s, k, v) diff --git a/demo/config/config_K_v.json b/demo/config/config_K_v.json index 41cf6f0..1dd9980 100644 --- a/demo/config/config_K_v.json +++ b/demo/config/config_K_v.json @@ -40,6 +40,7 @@ "弹幕_识别表情代码": true, "发送还有几天过期的礼物": 3, "保持牌子亮着": true, + "弹幕输出到日志": true, "保存弹幕至db": { "dbname": "", "url":"",