Skip to content

Commit 21bfa14

Browse files
committed
更改 ban 时间为 10 分
1 parent 0e2d717 commit 21bfa14

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

plugin/antiabuse/anti.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import (
1717
"github.com/wdvxdr1123/ZeroBot/message"
1818
)
1919

20-
const banhour = 4
20+
const bandur time.Duration = time.Minute * 10
2121

2222
var (
2323
managers *ctrl.Manager[*zero.Ctx] // managers lazy load
24-
cache = ttl.NewCacheOn(banhour*time.Hour, [4]func(int64, struct{}){nil, nil, onDel, nil})
24+
cache = ttl.NewCacheOn(bandur, [4]func(int64, struct{}){nil, nil, onDel, nil})
2525
db *antidb
2626
)
2727

@@ -69,8 +69,8 @@ func init() {
6969
if err := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).Manager.DoBlock(uid); err == nil {
7070
t := time.Now().Unix()
7171
cache.Set(uid, struct{}{})
72-
ctx.SetGroupBan(gid, uid, banhour*3600)
73-
ctx.SendChain(message.Text("检测到违禁词, 已封禁/屏蔽", banhour, "小时"))
72+
ctx.SetGroupBan(gid, uid, int64(bandur.Minutes()))
73+
ctx.SendChain(message.Text("检测到违禁词, 已封禁/屏蔽", bandur))
7474
db.Lock()
7575
defer db.Unlock()
7676
err := db.Create("__bantime__", nilbt)

plugin/antiabuse/db.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ var (
3131

3232
func newantidb(path string) (*antidb, error) {
3333
db := &antidb{Sqlite: sqlite.Sqlite{DBPath: path}}
34-
err := db.Open(time.Hour * banhour)
34+
err := db.Open(bandur)
3535
if err != nil {
3636
return nil, err
3737
}
3838
_ = db.FindFor("__bantime__", nilbt, "", func() error {
3939
t := time.Unix(nilbt.Time, 0)
40-
ttl := time.Until(t.Add(time.Hour * banhour))
40+
ttl := time.Until(t.Add(bandur))
4141
if ttl < time.Minute {
4242
_ = managers.DoUnblock(nilbt.ID)
4343
return nil
@@ -46,7 +46,7 @@ func newantidb(path string) (*antidb, error) {
4646
cache.Touch(nilbt.ID, -time.Since(t))
4747
return nil
4848
})
49-
_ = db.Del("__bantime__", "WHERE time<="+strconv.FormatInt(time.Now().Add(time.Minute-time.Hour*banhour).Unix(), 10))
49+
_ = db.Del("__bantime__", "WHERE time<="+strconv.FormatInt(time.Now().Add(time.Minute-bandur).Unix(), 10))
5050
return db, nil
5151
}
5252

0 commit comments

Comments
 (0)