From 8ec4271419a8c4fefe2b7884ccb85fe084ee5dbd Mon Sep 17 00:00:00 2001 From: fumiama Date: Sat, 15 Jan 2022 17:00:07 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20fix=20curse=20over-widely=20m?= =?UTF-8?q?atching?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin_curse/curse.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plugin_curse/curse.go b/plugin_curse/curse.go index a0b663d6..0037b7cb 100644 --- a/plugin_curse/curse.go +++ b/plugin_curse/curse.go @@ -13,20 +13,18 @@ import ( ) const ( - prio = 10 + prio = 300 minLevel = "min" maxLevel = "max" ) -var ( - engine = control.Register("curse", &control.Options{ - DisableOnDefault: false, +func init() { + limit := rate.NewManager(time.Minute, 30) + engine := control.Register("curse", &control.Options{ + DisableOnDefault: true, Help: "骂人(求骂,自卫)\n- 骂我\n- 大力骂我\n- @bot 他妈|公交车|你妈|操|屎|去死|快死|日|逼|尼玛|艾滋|癌症|有病|戴套|啊对对对|烦你|你爹|屮|tui|cnm", }) - limit = rate.NewManager(time.Minute, 30) -) -func init() { engine.OnFullMatch("骂我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) { if !limit.Load(ctx.Event.GroupID).Acquire() { return @@ -44,7 +42,8 @@ func init() { text := getRandomCurseByLevel(maxLevel).Text ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text)) }) - engine.OnKeywordGroup([]string{"他妈", "公交车", "你妈", "操", "屎", "去死", "快死", "日", "逼", "尼玛", "艾滋", "癌症", "有病", "戴套", "啊对对对", "烦你", "你爹", "屮", "tui", "cnm"}, zero.OnlyToMe).SetBlock(true).SetPriority(prio). + + engine.OnKeywordGroup([]string{"他妈", "公交车", "你妈", "操", "屎", "去死", "快死", "我日", "逼", "尼玛", "艾滋", "癌症", "有病", "烦你", "你爹", "屮", "cnm"}, zero.OnlyToMe).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { text := getRandomCurseByLevel(maxLevel).Text ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))