From a0572290d34e11b26ea0f8f3184da5f094e24962 Mon Sep 17 00:00:00 2001 From: qydysky <32743305+qydysky@users.noreply.github.com> Date: Sun, 26 Mar 2023 16:21:09 +0800 Subject: [PATCH] =?utf8?q?Improve=20=E7=A7=BB=E9=99=A4=E8=87=AA=E5=8A=A8?= =?utf8?q?=E4=B8=BE=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/F.go | 122 ++++++++++++++++++++++++------------------------ Reply/Reply.go | 12 ++--- Reply/stream.go | 12 ++--- 3 files changed, 73 insertions(+), 73 deletions(-) diff --git a/Reply/F.go b/Reply/F.go index 629c586..4d8a6e5 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -459,71 +459,71 @@ func StreamOStop(roomid int) { // } // } -type Autoban struct { - Banbuf []string - buf []string -} - -var autoban = Autoban{} - -func Autobanf(s string) bool { - if !IsOn("Autoban") { - return false - } +// type Autoban struct { +// Banbuf []string +// buf []string +// } - l := c.C.Log.Base("autoban") +// var autoban = Autoban{} - if len(autoban.Banbuf) == 0 { - f := file.New("Autoban.txt", -1, false) - for { - if data, e := f.ReadUntil('\n', 50, 5000); e != nil { - if !errors.Is(e, io.EOF) { - l.L(`E: `, e) - } - break - } else { - autoban.Banbuf = append(autoban.Banbuf, string(data)) - } - } - } - - if len(autoban.buf) < 10 { - autoban.buf = append(autoban.buf, s) - return false - } - defer func() { - autoban.buf = append(autoban.buf[1:], s) - }() +// func Autobanf(s string) bool { +// if !IsOn("Autoban") { +// return false +// } - var res []float32 - { - pt := float32(len([]rune(s))) - if pt <= 5 { - return false - } //字数过少去除 - res = append(res, pt) - } - { - pt := selfcross(s) - // if pt > 0.5 {return false}//自身重复高去除 - // res = append(res, pt) +// l := c.C.Log.Base("autoban") + +// if len(autoban.Banbuf) == 0 { +// f := file.New("Autoban.txt", -1, false) +// for { +// if data, e := f.ReadUntil('\n', 50, 5000); e != nil { +// if !errors.Is(e, io.EOF) { +// l.L(`E: `, e) +// } +// break +// } else { +// autoban.Banbuf = append(autoban.Banbuf, string(data)) +// } +// } +// } - pt1 := cross(s, autoban.buf) - if pt+pt1 > 0.3 { - return false - } //历史重复高去除 - res = append(res, pt, pt1) - } - { - pt := cross(s, autoban.Banbuf) - if pt < 0.8 { - return false - } //ban字符重复低去除 - res = append(res, pt) - } - l.L(`W: `, res) - return true -} +// if len(autoban.buf) < 10 { +// autoban.buf = append(autoban.buf, s) +// return false +// } +// defer func() { +// autoban.buf = append(autoban.buf[1:], s) +// }() + +// var res []float32 +// { +// pt := float32(len([]rune(s))) +// if pt <= 5 { +// return false +// } //字数过少去除 +// res = append(res, pt) +// } +// { +// pt := selfcross(s) +// // if pt > 0.5 {return false}//自身重复高去除 +// // res = append(res, pt) + +// pt1 := cross(s, autoban.buf) +// if pt+pt1 > 0.3 { +// return false +// } //历史重复高去除 +// res = append(res, pt, pt1) +// } +// { +// pt := cross(s, autoban.Banbuf) +// if pt < 0.8 { +// return false +// } //ban字符重复低去除 +// res = append(res, pt) +// } +// l.L(`W: `, res) +// return true +// } type Danmuji struct { Buf map[string]string diff --git a/Reply/Reply.go b/Reply/Reply.go index d6857aa..7d627fa 100644 --- a/Reply/Reply.go +++ b/Reply/Reply.go @@ -1099,12 +1099,12 @@ func (replyF) danmu(s string) { { //附加功能 弹幕机 封禁 弹幕合并 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 - } + // 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 + // } if i := Autoskipf(item.msg); i > 0 { msglog.L(`I: `, item.auth, ":", item.msg) return diff --git a/Reply/stream.go b/Reply/stream.go index c75b549..d61df9d 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -661,12 +661,12 @@ func (t *M4SStream) saveStreamFlv() (e error) { } // 如果被主动关闭,则退出saveStreamFlv,否则继续尝试其他live - s := signal.Init() + needStop := signal.Init() { go func() { tsc, tscf := t.Status.WaitC() defer tscf() - sc, scf := s.WaitC() + sc, scf := needStop.WaitC() defer scf() select { @@ -689,7 +689,7 @@ func (t *M4SStream) saveStreamFlv() (e error) { timer := time.NewTicker(5 * time.Second) defer timer.Stop() - sc, scf := s.WaitC() + sc, scf := needStop.WaitC() defer scf() for { @@ -707,7 +707,7 @@ func (t *M4SStream) saveStreamFlv() (e error) { if t.config.want_qn != int(v) { t.log.L(`I: `, "直播流清晰度改变:", t.common.Qn[t.config.want_qn], "=>", t.common.Qn[int(v)]) t.config.want_qn = int(v) - s.Done() + needStop.Done() r.Cancel() return } @@ -812,8 +812,8 @@ func (t *M4SStream) saveStreamFlv() (e error) { } t.reqPool.Put(r) - if s.Islive() { - s.Done() + if needStop.Islive() { + needStop.Done() } else { return } -- 2.39.2