@@ -17,7 +17,12 @@ import (
17
17
"github.com/wdvxdr1123/ZeroBot/message"
18
18
)
19
19
20
- const bandur time.Duration = time .Minute * 2
20
+ const (
21
+ bandur time.Duration = time .Minute * 2
22
+ add = "添加违禁词"
23
+ delete = "删除违禁词"
24
+ list = "查看违禁词"
25
+ )
21
26
22
27
var (
23
28
managers * ctrl.Manager [* zero.Ctx ] // managers lazy load
@@ -56,7 +61,14 @@ func init() {
56
61
return true
57
62
})
58
63
59
- engine .OnMessage (onceRule , zero .OnlyGroup , func (ctx * zero.Ctx ) bool {
64
+ notAntiabuse := func (ctx * zero.Ctx ) bool {
65
+ if zero .PrefixRule (add )(ctx ) || zero .PrefixRule (delete )(ctx ) || zero .PrefixRule (list )(ctx ) {
66
+ return false
67
+ }
68
+ return true
69
+ }
70
+
71
+ engine .OnMessage (notAntiabuse , zero .OnlyGroup , func (ctx * zero.Ctx ) bool {
60
72
uid := ctx .Event .UserID
61
73
gid := ctx .Event .GroupID
62
74
msg := strings .ReplaceAll (ctx .MessageString (), "\n " , "" )
@@ -67,7 +79,7 @@ func init() {
67
79
if err := ctx .State ["manager" ].(* ctrl.Control [* zero.Ctx ]).Manager .DoBlock (uid ); err == nil {
68
80
t := time .Now ().Unix ()
69
81
cache .Set (uid , struct {}{})
70
- ctx .SetThisGroupBan (uid , int64 (bandur .Minutes ()))
82
+ ctx .SetThisGroupBan (uid , int64 (bandur .Seconds ()))
71
83
ctx .DeleteMessage (ctx .Event .MessageID )
72
84
ctx .SendChain (message .Text ("检测到违禁词, 已封禁/屏蔽" , bandur ))
73
85
db .Lock ()
@@ -90,7 +102,7 @@ func init() {
90
102
return true
91
103
})
92
104
93
- engine .OnPrefix ("添加违禁词" , zero .OnlyGroup , zero .AdminPermission , onceRule ).Handle (
105
+ engine .OnPrefix ("添加违禁词" , zero .OnlyGroup , zero .AdminPermission , onceRule ).SetBlock ( true ). Handle (
94
106
func (ctx * zero.Ctx ) {
95
107
args := strings .TrimSpace (ctx .State ["args" ].(string ))
96
108
if err := db .insertWord (ctx .Event .GroupID , args ); err != nil {
@@ -100,7 +112,7 @@ func init() {
100
112
}
101
113
})
102
114
103
- engine .OnPrefix ("删除违禁词" , zero .OnlyGroup , zero .AdminPermission , onceRule ).Handle (
115
+ engine .OnPrefix ("删除违禁词" , zero .OnlyGroup , zero .AdminPermission , onceRule ).SetBlock ( true ). Handle (
104
116
func (ctx * zero.Ctx ) {
105
117
args := strings .TrimSpace (ctx .State ["args" ].(string ))
106
118
if err := db .deleteWord (ctx .Event .GroupID , args ); err != nil {
@@ -110,7 +122,7 @@ func init() {
110
122
}
111
123
})
112
124
113
- engine .OnPrefix ("查看违禁词" , zero .OnlyGroup , onceRule ).Handle (
125
+ engine .OnPrefix ("查看违禁词" , zero .OnlyGroup , onceRule ).SetBlock ( true ). Handle (
114
126
func (ctx * zero.Ctx ) {
115
127
b , err := text .RenderToBase64 (db .listWords (ctx .Event .GroupID ), text .FontFile , 400 , 20 )
116
128
if err != nil {
0 commit comments