✏️ 修正正则与cd认证

This commit is contained in:
fumiama 2021-10-29 12:48:56 +08:00
parent 9608d1e736
commit f9ce439e56
2 changed files with 15 additions and 14 deletions

View File

@ -30,10 +30,9 @@ func init() {
ctx.DeleteMessage(id) ctx.DeleteMessage(id)
}) })
zero.OnRegex("^●cd([\u4e00-\u9fa5]{4})$", zero.OnlyGroup).SetBlock(true).FirstPriority(). zero.OnRegex("^●cd([\u4e00-\u8e00]{4})$", zero.OnlyGroup).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
tok := ctx.State["regex_matched"].([]string)[1] if isValidToken(ctx.State["regex_matched"].([]string)[1]) {
if isValidToken(tok) && time.Now().Unix()-startTime < 10 {
msg := "" msg := ""
gid := ctx.Event.GroupID gid := ctx.Event.GroupID
ForEach(func(key string, manager *Control) bool { ForEach(func(key string, manager *Control) bool {
@ -54,17 +53,19 @@ func init() {
} }
}) })
zero.OnRegex("^●cd●(.*)", zero.OnlyGroup).SetBlock(true).FirstPriority(). zero.OnRegex("^●cd●(([\u4e00-\u8e00]*[\u3d01-\u3d06]?))", zero.OnlyGroup).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
msg, err := b14.UTF82utf16be(helper.StringToBytes(ctx.State["regex_matched"].([]string)[1])) if time.Now().Unix()-startTime < 10 {
if err == nil { msg, err := b14.UTF82utf16be(helper.StringToBytes(ctx.State["regex_matched"].([]string)[1]))
gid := ctx.Event.GroupID if err == nil {
for _, s := range strings.Split(b14.DecodeString(msg), "\xfe\xff") { gid := ctx.Event.GroupID
mu.RLock() for _, s := range strings.Split(b14.DecodeString(msg), "\xfe\xff") {
c, ok := managers[s] mu.RLock()
mu.RUnlock() c, ok := managers[s]
if ok && c.IsEnabledIn(gid) { mu.RUnlock()
c.Disable(gid) if ok && c.IsEnabledIn(gid) {
c.Disable(gid)
}
} }
} }
} }

View File

@ -25,7 +25,7 @@ func init() {
ctx.SendChain(message.Text("加密失败!")) ctx.SendChain(message.Text("加密失败!"))
} }
}) })
en.OnRegex("^解密([\u4e00-\u9fa5]*[\u3d01-\u3d06]?)$").SetBlock(true).ThirdPriority(). en.OnRegex("^解密([\u4e00-\u8e00]*[\u3d01-\u3d06]?)$").SetBlock(true).ThirdPriority().
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
str := ctx.State["regex_matched"].([]string)[1] str := ctx.State["regex_matched"].([]string)[1]
es, err := base14.UTF82utf16be(helper.StringToBytes(str)) es, err := base14.UTF82utf16be(helper.StringToBytes(str))