]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
消息保存json
authorqydysky <qydysky@foxmail.com>
Tue, 26 Jan 2021 15:57:39 +0000 (23:57 +0800)
committerqydysky <qydysky@foxmail.com>
Tue, 26 Jan 2021 15:57:39 +0000 (23:57 +0800)
Reply/F.go
Reply/Reply.go
bili_danmu.go
demo/config/config_K_v.json

index ff962651c4b70243bd027008e5c249e6645552a9..9578999c8e2b9dddf7a11fa772587be916840342 100644 (file)
@@ -720,4 +720,26 @@ func Jiezouf(s []string) bool {
        }
        jiezou.Unlock()
        return false
+}
+
+//保存所有消息到json
+func init(){
+       Save_to_json(0, []interface{}{`[`})
+       c.Danmu_Main_mq.Pull_tag(map[string]func(interface{})(bool){
+               `change_room`:func(data interface{})(bool){//房间改变
+                       Save_to_json(0, []interface{}{`[`})
+                       return false
+               },
+       })
+}
+
+func Save_to_json(Loc int,Context []interface{}) {
+       if path,ok := K_v[`save_to_json`].(string);ok && path != ``{
+               p.File().FileWR(p.Filel{
+                       File:path,
+                       Write:true,
+                       Loc:int64(Loc),
+                       Context:Context,
+               })
+       }
 }
\ No newline at end of file
index b91f6a09ae0b7b0fec5907a6b20e8a282bb7628f..fc326f2b69e8ec822b94d2c694f1fea443706417 100644 (file)
@@ -43,7 +43,9 @@ func Reply(b []byte) {
                
                contain := b[c.WS_PACKAGE_HEADER_TOTAL_LENGTH:head.PackL]
                switch head.OpeaT {
-               case c.WS_OP_MESSAGE:Msg(contain)
+               case c.WS_OP_MESSAGE:
+                       Msg(contain)
+                       Save_to_json(-1, []interface{}{contain,`,`})
                case c.WS_OP_HEARTBEAT_REPLY:Heart(contain)
                default :reply_log.L(`W: `,"unknow reply", contain)
                }
index 832fdf949b185f1e087423ab20a41bd6f994e833..da796a8bc175d15bfe8301fc890e375d70c7cd48 100644 (file)
@@ -262,6 +262,7 @@ func Demo(roomid ...int) {
                close(interrupt)
                {//附加功能 直播流
                        reply.Saveflv_wait()
+                       reply.Save_to_json(-1, []interface{}{`{}]`})
                }
                danmulog.L(`I: `,"结束退出")
        }
index c26829c68a657b5b90840ee475d86b2f5209631e..bb29f8c21bc985659e6f03d972dcf67e4e2f63cb 100644 (file)
@@ -17,5 +17,8 @@
     "gtk":"GTK相关",
     "gtk_保留弹幕数量":25,
     "gtk_内存头像数量":30,
-    "gtk_头像获取等待最大数量":30
+    "gtk_头像获取等待最大数量":30,
+
+    "save_to_json-help":"保存消息设置,将所有消息保存为json文件,输入文件名(带后缀)",
+    "save_to_json":""
 }
\ No newline at end of file