]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
将旧额外功能的配置合并到新K_v.json中
authorqydysky <qydysky@foxmail.com>
Sat, 20 Feb 2021 02:04:36 +0000 (10:04 +0800)
committerqydysky <qydysky@foxmail.com>
Sat, 20 Feb 2021 02:04:36 +0000 (10:04 +0800)
F/api.go
README.md
Reply/0Init.go [deleted file]
Reply/F.go
Reply/gtk.go
bili_danmu.go
demo/config/config_F.json [deleted file]
demo/config/config_K_v.json

index ce108774b05fb8bd7a550ff40cfe50ee75b94abe..6b02d075022355a9ecb9460926c8cf09b1237f3e 100644 (file)
--- a/F/api.go
+++ b/F/api.go
@@ -164,7 +164,7 @@ func (i *api) Get_info() (o *api) {
                if tmp.Data.Room_info.Uid != 0{
                        o.Uid = tmp.Data.Room_info.Uid
                } else {
-                       apilog.L(`E: `,"data.room_info.parent_area_id = 0")
+                       apilog.L(`W: `,"data.room_info.Uid = 0")
                        return
                }
 
@@ -172,13 +172,13 @@ func (i *api) Get_info() (o *api) {
                if tmp.Data.Room_info.Parent_area_id != 0{
                        o.Parent_area_id = tmp.Data.Room_info.Parent_area_id
                } else {
-                       apilog.L(`E: `,"data.room_info.parent_area_id = 0")
+                       apilog.L(`W: `,"直播间未设置主分区!")
                        return
                }
                if tmp.Data.Room_info.Area_id != 0{
                        o.Area_id = tmp.Data.Room_info.Area_id
                } else {
-                       apilog.L(`E: `,"data.room_info.Area_id = 0")
+                       apilog.L(`W: `,"直播间未设置分区!")
                        return
                }
 
@@ -186,7 +186,7 @@ func (i *api) Get_info() (o *api) {
                if tmp.Data.Room_info.Room_id != 0{
                        o.Roomid = tmp.Data.Room_info.Room_id
                } else {
-                       apilog.L(`E: `,"data.room_info.room_id = 0")
+                       apilog.L(`W: `,"data.room_info.room_id = 0")
                        return
                }
                
@@ -194,7 +194,7 @@ func (i *api) Get_info() (o *api) {
                if tmp.Data.Room_info.Title != ``{
                        c.Title = tmp.Data.Room_info.Title
                } else {
-                       apilog.L(`E: `,"data.room_info.title = ''")
+                       apilog.L(`W: `,"直播间无标题")
                        return
                }
 
index eeb8dc16e48d2e3cdfe86c15ba2faa228c059a21..0aed7154e6a5ff674ce39fefa7a18a5d81147dce 100644 (file)
--- a/README.md
+++ b/README.md
@@ -58,7 +58,7 @@ golang go version go1.15 linux/amd64
 - [x] 排行榜
 
 #### 当前支持功能
-以下内容可能过时,点击查看[当前支持功能(旧)](https://github.com/qydysky/bili_danmu/blob/master/Reply/F.go#L16),[功能配置(新)](https://github.com/qydysky/bili_danmu/blob/maintenance/demo/config/config_K_v.json)
+以下内容可能过时,点击查看[~~当前支持功能(旧)~~](https://github.com/qydysky/bili_danmu/blob/9731f69d06a15645c6cb1d41379520a5a3f519f1/Reply/F.go#L26),[功能配置(新)](https://github.com/qydysky/bili_danmu/blob/maintenance/demo/config/config_K_v.json)
 - [x] 银瓜子自动兑换硬币(日期更迭会触发)
 - [x] 可选有无粉丝牌发进房弹幕(有粉丝牌每日首条弹幕有经验)(日期更迭会触发)
 - [x] 签到(日期更迭会触发)
diff --git a/Reply/0Init.go b/Reply/0Init.go
deleted file mode 100644 (file)
index 039ec6d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package reply
-
-import (
-       s "github.com/qydysky/part/buf"
-)
-
-//从config.json初始化
-func init(){
-       buf := s.New()
-       buf.Load("config/config_F.json")
-       for k,v := range buf.B {
-               AllF[k] = v.(bool)
-       }
-} 
index ee4db4365273e5bbb65e6e94ceee7080244acb31..1bcf21839cedb0074d50459928c7f5b21eaa8a6c 100644 (file)
@@ -24,34 +24,10 @@ import (
        F额外功能区
 */
 
-//功能开关
-var AllF = map[string]bool{
-       `ShowRev`:true,//显示本次营收
-       "Gtk":false,//Gtk弹幕窗口(使用go build -tags 'gtk gtk_3_24'编译,linux only)
-       "Saveflv":true,//保存直播流(默认高清,有cookie默认蓝光)
-       "Ass":true,//Ass弹幕生成,由于时间对应关系,仅开启流保存时生效
-       "Obs":false,//obs组件(仅录播)
-       /*
-               Obs需要外部组件:
-               obs https://obsproject.com/download
-               obs-websocket https://github.com/Palakis/obs-websocket/releases
-       */
-       "Autoban":false,//自动封禁(仅提示,未完成)
-       "Jiezou":true,//带节奏预警,提示弹幕礼仪
-       "Danmuji":true,//反射型弹幕机,回应弹幕
-       "Danmuji_auto":false,//自动型弹幕机,定时输出
-       "Autoskip":true,//刷屏缩减,相同合并
-       "Lessdanmu":true,//弹幕缩减,屏蔽与前n条弹幕重复的字数占比度高于阈值的弹幕
-       "Moredanmu":false,//弹幕增量
-       "Shortdanmu":true,//上下文相同文字缩减
-}
-
 //功能开关选取函数
 func IsOn(s string) bool {
-       if v, ok := AllF[s]; ok && v {
-               return true
-       }
-       return false
+       v, ok := c.K_v.LoadV(s).(bool)
+       return ok && v
 }
 
 //字符重复度检查
@@ -117,7 +93,7 @@ var (
 )
 
 func ShowRevf(){
-       if!IsOn("ShowRev") {return}
+       if!IsOn("统计营收") {return}
        if ShowRev_start {
                c.Log.Base(`功能`).L(`I: `, fmt.Sprintf("营收 ¥%.2f",c.Rev))
                return
@@ -181,7 +157,7 @@ func Ass_f(file string, st time.Time){
 
 //传入要显示的单条字幕
 func Assf(s string){
-       if !IsOn("Ass") {return}
+       if !IsOn("生成Ass弹幕") {return}
        if ass.file == "" {return}
 
        if s == "" {return}
@@ -224,7 +200,7 @@ var saveflv = Saveflv {
 
 //已go func形式调用,将会获取直播流
 func Saveflvf(){
-       if !IsOn("Saveflv") {return}
+       if !IsOn("保存flv直播流") {return}
        if saveflv.cancel.Islive() {return}
 
        l := c.Log.Base(`saveflv`)
@@ -234,7 +210,7 @@ func Saveflvf(){
        for api.Get_live(c.Live_qn).Live_status == 1 {
                c.Live = api.Live
 
-               saveflv.path = strconv.Itoa(c.Roomid) + "_" + time.Now().Format("2006_01_02_15:04:05.000")
+               saveflv.path = strconv.Itoa(c.Roomid) + "_" + time.Now().Format("2006_01_02_15-04-05-000")
 
                saveflv.wait = s.Init()
                saveflv.cancel = s.Init()
@@ -321,7 +297,7 @@ func Saveflvf(){
 
 //已func形式调用,将会停止保存直播流
 func Saveflv_wait(){
-       if !IsOn("Saveflv") {return}
+       if !IsOn("保存flv直播流") {return}
        saveflv.cancel.Done()
        c.Log.Base(`saveflv`).L(`I: `,"等待")
        saveflv.wait.Wait()
@@ -338,7 +314,7 @@ var obs = Obs {
 }
 
 func Obsf(on bool){
-       if !IsOn("Obs") {return}
+       if !IsOn("调用obs") {return}
        l := c.Log.Base(`obs`)
 
        if on {
@@ -365,7 +341,7 @@ func Obsf(on bool){
 }
 
 func Obs_R(on bool){
-       if !IsOn("Obs") {return}
+       if !IsOn("调用obs") {return}
 
        l := c.Log.Base("obs_R")
 
@@ -473,7 +449,7 @@ type Danmuji struct {
 }
 
 var danmuji = Danmuji{
-       Inuse_auto:IsOn("Danmuji_auto"),
+       Inuse_auto:IsOn("自动弹幕机"),
        Buf:map[string]string{
                "弹幕机在么":"在",
        },
@@ -488,26 +464,32 @@ func init(){//初始化反射型弹幕机
 }
 
 func Danmujif(s string) {
-       if !IsOn("Danmuji") {return}
+       if !IsOn("反射弹幕机") {return}
        if v, ok := danmuji.Buf[s]; ok {
                Msg_senddanmu(v)
        }
 }
 
-func Danmuji_auto(sleep int) {
-       if !IsOn("Danmuji") || !IsOn("Danmuji_auto") || danmuji.mute {return}
-       if sleep == 0 {return}
+func Danmuji_auto() {
+       if !IsOn("反射弹幕机") || !IsOn("自动弹幕机") || danmuji.mute {return}
 
        danmuji.mute = true
-       var list = []string{
-               "当前正在直播",
-               "12345",
+
+       var (
+               list []string
+               timeout int
+       )
+       for _,v := range c.K_v.LoadV(`自动弹幕机_内容`).([]interface{}){
+               list = append(list, v.(string))
        }
+       timeout = int(c.K_v.LoadV(`自动弹幕机_发送间隔s`).(float64))
+       if timeout < 5 {timeout = 5}
+
        go func(){
                for i := 0; true; i++{
                        if i >= len(list) {i = 0}
-                       Msg_senddanmu(list[i])
-                       p.Sys().Timeoutf(sleep)
+                       if msg := list[i];msg != ``{Msg_senddanmu(msg)}
+                       p.Sys().Timeoutf(timeout)
                }
        }()
 }
@@ -559,7 +541,7 @@ func init(){
 }
 
 func Autoskipf(s string) uint {
-       if !IsOn("Autoskip") || s == ""{return 0}
+       if !IsOn("弹幕合并") || s == ""{return 0}
        autoskip.Lock()
        defer autoskip.Unlock()
        {//验证是否已经存在
@@ -588,7 +570,7 @@ var lessdanmu = Lessdanmu{
 }
 
 func Lessdanmuf(s string, bufsize int) float32 {
-       if !IsOn("Lessdanmu") {return 0}
+       if !IsOn("相似弹幕忽略") {return 0}
        if len(lessdanmu.buf) < bufsize {
                lessdanmu.buf = append(lessdanmu.buf, s)
                return 0
@@ -664,7 +646,7 @@ var shortdanmu = Shortdanmu{
 }
 
 func Shortdanmuf(s string) string {
-       if !IsOn("Shortdanmu") {return s}
+       if !IsOn("精简弹幕") {return s}
        if len(shortdanmu.lastdanmu) == 0 {shortdanmu.lastdanmu = []rune(s);return s}
 
        var new string
index dffa4840eed749701fc03dacca0d90fb251c2d57..7784d82b3b32e5db8dc000702f04ad5c23451a4f 100644 (file)
@@ -70,7 +70,7 @@ var (
 )
 
 func init(){
-       if!IsOn("Gtk") {return}
+       if!IsOn("Gtk弹幕窗") {return}
        go Gtk_danmu()
        //使用带tag的消息队列在功能间传递消息
        Danmu_mq.Pull_tag(msgq.FuncMap{
@@ -394,7 +394,7 @@ func Gtk_danmu() {
                                }
                        }
                        {//营收
-                               if IsOn("ShowRev") {
+                               if IsOn("统计营收") {
                                        b,e := w2_textView0.GetBuffer()
                                        if e != nil {log.Println(e);return}
                                        b.SetText(fmt.Sprintf("¥%.2f",c.Rev))                                 
index 748691c3fa1cc82520960f23ce8c3930934971bb..3aa08deb8fbad5ecaa54140c483fa878600b7c13 100644 (file)
@@ -257,7 +257,7 @@ func Demo(roomid ...int) {
                                                })
 
                                                if c.Cookie.Len() != 0 {//附加功能 弹幕机 无cookie无法发送弹幕
-                                                       reply.Danmuji_auto(1)
+                                                       reply.Danmuji_auto()
                                                }
                                                {//附加功能 进房间发送弹幕 直播流保存 营收
                                                        go reply.Entry_danmu()
diff --git a/demo/config/config_F.json b/demo/config/config_F.json
deleted file mode 100644 (file)
index a2ba5e2..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-{
-    "ShowRev":true,
-    "Gtk": true,
-    "Qtd": false,
-    "Saveflv": false,
-    "Ass": true,
-    "Obs": false,
-    "Autoban": false,
-    "Jiezou": false,
-    "Danmuji": true,
-    "Danmuji_auto": false,
-    "Autoskip": true,
-    "Lessdanmu": true,
-    "Moredanmu": false,
-    "Shortdanmu": true
-}
\ No newline at end of file
index a9ce995281ffee3cf21d4cc3754b3eb1c7da4fe3..ad9aa8c0e3879b95f47fa21aaa41d105fd8f74c0 100644 (file)
 
     "进房弹幕-help":"进入房间发送弹幕",
     "进房弹幕_内容":" ",
-    "进房弹幕_有粉丝牌时才发":true
+    "进房弹幕_有粉丝牌时才发":true,
+
+    "其他":"",
+    "统计营收":true,
+    "Gtk弹幕窗":true,
+    "调用obs":false,
+    
+    "直播流":"",
+    "保存flv直播流":true,
+    "生成Ass弹幕":true,
+
+    "弹幕处理":"",
+    "弹幕合并":true,
+    "相似弹幕忽略":true,
+    "精简弹幕":true,
+
+    "弹幕机":"",
+    "反射弹幕机":true,
+    "自动弹幕机":false,
+    "自动弹幕机-help":"间隔最小5s,空字符串不会发送但仍会等待",
+    "自动弹幕机_内容":["hhh",""],
+    "自动弹幕机_发送间隔s":30
 }
\ No newline at end of file