Skip to content

Commit

Permalink
feat(manager): onregex -> pattern (#1082)
Browse files Browse the repository at this point in the history
* feat(manager): onregex -> pattern

* delete nil
  • Loading branch information
xyy0411 authored Dec 14, 2024
1 parent 38eae93 commit 37818ac
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions plugin/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ func init() { // 插件主体
ctx.SendChain(message.Text("全员自闭结束~"))
})
// 禁言
engine.OnRegex(`^禁言.*?(\d+).*?\s(\d+)(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
engine.OnMessage(zero.NewPattern().Text("^禁言").At().Text("(\\d+)\\s*(.*)").AsRule(), zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
duration := math.Str2Int64(ctx.State["regex_matched"].([]string)[2])
switch ctx.State["regex_matched"].([]string)[3] {
parsed := ctx.State[zero.KeyPattern].([]zero.PatternParsed)
duration := math.Str2Int64(parsed[2].Text()[1])
switch parsed[2].Text()[2] {
case "分钟":
//
case "小时":
Expand All @@ -172,9 +173,9 @@ func init() { // 插件主体
if duration >= 43200 {
duration = 43199 // qq禁言最大时长为一个月
}
ctx.SetThisGroupBan(
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 要禁言的人的qq
duration*60, // 要禁言的时间(分钟)
ctx.SetThisGroupBan(
math.Str2Int64(parsed[1].At()), // 要禁言的人的qq
duration*60, // 要禁言的时间(分钟)
)
ctx.SendChain(message.Text("小黑屋收留成功~"))
})
Expand Down

0 comments on commit 37818ac

Please sign in to comment.