]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
10
authorqydysky <qydysky@foxmail.com>
Tue, 15 Sep 2020 10:34:29 +0000 (18:34 +0800)
committerqydysky <qydysky@foxmail.com>
Tue, 15 Sep 2020 10:34:29 +0000 (18:34 +0800)
.gitignore
F.go [new file with mode: 0644]
Msg.go
bili_danmu.go

index 8aea175ad4e00f1b038405c9281f4343adcfb3a3..beb92ad41bfe2682836b1a6023a7167baea1d812 100644 (file)
@@ -4,3 +4,6 @@ a.json
 demo/cookie.txt
 player-loader-2.0.4.min.js
 pv-tracker.js
+demo/Autoban.txt
+demo/his/danmu.log
+danmu.log
diff --git a/F.go b/F.go
new file mode 100644 (file)
index 0000000..12f4048
--- /dev/null
+++ b/F.go
@@ -0,0 +1,46 @@
+package bili_danmu
+
+import (
+       "bytes"
+
+       p "github.com/qydysky/part"
+) 
+
+type Autoban struct {
+       buf []byte
+       Inuse bool
+}
+
+var autoban = Autoban {
+       Inuse:true,
+}
+
+func Autobanf(s string) float32 {
+       if autoban.Inuse {return 0}
+
+       if len(autoban.buf) == 0 {
+               f := p.File().FileWR(p.Filel{
+                       File:"Autoban.txt",
+                       Write:false,
+               })
+               autoban.buf = []byte(f)
+       }
+
+       var scop int
+       for _, v := range []byte(s) {
+               if bytes.Contains(autoban.buf, []byte{v}) {scop += 1}
+       }
+       return float32(scop) / float32(len(s))
+}
+
+func Autoban_add(s string) {
+       if autoban.Inuse {return}
+
+       autoban.buf = append(autoban.buf, []byte(s)...)
+       p.File().FileWR(p.Filel{
+               File:"Autoban.txt",
+               Write:true,
+               Loc:-1,
+               Context:[]interface{}{s},
+       })
+}
\ No newline at end of file
diff --git a/Msg.go b/Msg.go
index a12e1e0729e1fc20920a60b35c9a98e043fe466b..1f8d859cd4a4f3c8e12f92994acc710cd772565d 100644 (file)
--- a/Msg.go
+++ b/Msg.go
@@ -253,6 +253,7 @@ func danmu(s string) {
                msg := infob[1].(string)
                auth := infob[2].([]interface{})[1].(string)
 
+               if Autobanf(msg) > 0.5 {msglog.Base(1, "风险").I(msg)}
                if Msg_roomid != 0 && Msg_cookie != "" && msg == "弹幕机在么" {Danmu_s("在", Msg_cookie, Msg_roomid)}
 
                msglog.I(auth, ":", msg)
index 86e809d63bc756ec0ded7bb4596e0f9a0e185f0a..e0ce16a64d479e46949c623740cfaa7f6510e7d4 100644 (file)
@@ -150,7 +150,7 @@ func headChe(head []byte, datalenght,Bodyv,Opeation,Sequence,show int) (bool,int
        if len(head) != WS_PACKAGE_HEADER_TOTAL_LENGTH {return false, 0}
        
        danmulog.Base(-1, "头部检查").Level(show)
-       defer danmulog.Base(0)
+       defer danmulog.Base(0).Level(LogLevel)
 
        packL := Btoi32(head[:4])
        headL := Btoi16(head[4:6])