@@ -17,7 +17,7 @@ import (
17
17
"github.com/wdvxdr1123/ZeroBot/message"
18
18
)
19
19
20
- const bandur time.Duration = time .Minute * 10
20
+ const bandur time.Duration = time .Minute * 2
21
21
22
22
var (
23
23
managers * ctrl.Manager [* zero.Ctx ] // managers lazy load
@@ -41,7 +41,7 @@ func init() {
41
41
engine := control .AutoRegister (& ctrl.Options [* zero.Ctx ]{
42
42
DisableOnDefault : false ,
43
43
Brief : "违禁词检测" ,
44
- Help : "- / [添加|删除|查看]违禁词" ,
44
+ Help : "- [添加|删除|查看]违禁词" ,
45
45
PrivateDataFolder : "anti_abuse" ,
46
46
})
47
47
@@ -57,9 +57,6 @@ func init() {
57
57
})
58
58
59
59
engine .OnMessage (onceRule , zero .OnlyGroup , func (ctx * zero.Ctx ) bool {
60
- if ! ctx .Event .IsToMe {
61
- return true
62
- }
63
60
uid := ctx .Event .UserID
64
61
gid := ctx .Event .GroupID
65
62
msg := strings .ReplaceAll (ctx .MessageString (), "\n " , "" )
@@ -71,6 +68,7 @@ func init() {
71
68
t := time .Now ().Unix ()
72
69
cache .Set (uid , struct {}{})
73
70
ctx .SetThisGroupBan (uid , int64 (bandur .Minutes ()))
71
+ ctx .DeleteMessage (ctx .Event .MessageID )
74
72
ctx .SendChain (message .Text ("检测到违禁词, 已封禁/屏蔽" , bandur ))
75
73
db .Lock ()
76
74
defer db .Unlock ()
@@ -92,27 +90,27 @@ func init() {
92
90
return true
93
91
})
94
92
95
- engine .OnCommand ("添加违禁词" , zero .OnlyGroup , zero .AdminPermission , onceRule ).Handle (
93
+ engine .OnPrefix ("添加违禁词" , zero .OnlyGroup , zero .AdminPermission , onceRule ).Handle (
96
94
func (ctx * zero.Ctx ) {
97
- args := ctx .State ["args" ].(string )
95
+ args := strings . TrimSpace ( ctx .State ["args" ].(string ) )
98
96
if err := db .insertWord (ctx .Event .GroupID , args ); err != nil {
99
97
ctx .SendChain (message .Text ("ERROR: " , err ))
100
98
} else {
101
99
ctx .SendChain (message .Text ("成功" ))
102
100
}
103
101
})
104
102
105
- engine .OnCommand ("删除违禁词" , zero .OnlyGroup , zero .AdminPermission , onceRule ).Handle (
103
+ engine .OnPrefix ("删除违禁词" , zero .OnlyGroup , zero .AdminPermission , onceRule ).Handle (
106
104
func (ctx * zero.Ctx ) {
107
- args := ctx .State ["args" ].(string )
105
+ args := strings . TrimSpace ( ctx .State ["args" ].(string ) )
108
106
if err := db .deleteWord (ctx .Event .GroupID , args ); err != nil {
109
107
ctx .SendChain (message .Text ("ERROR: " , err ))
110
108
} else {
111
109
ctx .SendChain (message .Text ("成功" ))
112
110
}
113
111
})
114
112
115
- engine .OnCommand ("查看违禁词" , zero .OnlyGroup , onceRule ).Handle (
113
+ engine .OnPrefix ("查看违禁词" , zero .OnlyGroup , onceRule ).Handle (
116
114
func (ctx * zero.Ctx ) {
117
115
b , err := text .RenderToBase64 (db .listWords (ctx .Event .GroupID ), text .FontFile , 400 , 20 )
118
116
if err != nil {
0 commit comments