diff --git a/README.md b/README.md index ba146fdc..9405c0ec 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,7 @@ zerobot [-h] [-n nickname] [-t token] [-u url] [-p prefix] [-d|w] [-c|s config.j `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus"` - [x] 切换[kimo|傲娇|可爱]词库 + - [x] 设置词库触发概率0.x (0
diff --git a/plugin/thesaurus/chat.go b/plugin/thesaurus/chat.go index 3ba82c1d..f5886e61 100644 --- a/plugin/thesaurus/chat.go +++ b/plugin/thesaurus/chat.go @@ -21,7 +21,7 @@ func init() { engine := control.Register("thesaurus", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "词典匹配回复", - Help: "- 切换[kimo|傲娇|可爱]词库", + Help: "- 切换[kimo|傲娇|可爱]词库\n- 设置词库触发概率0.x (0= 9 { + ctx.SendChain(message.Text("ERROR: 概率越界")) + return + } + n-- // 0~7 + gid := ctx.Event.GroupID + if gid == 0 { + gid = -ctx.Event.UserID + } + d := c.GetData(gid) + err := c.SetData(gid, (d&3)|(int64(n)<<59)) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return @@ -142,6 +167,9 @@ const ( func canmatch(typ int64) zero.Rule { return func(ctx *zero.Ctx) bool { + if zero.HasPicture(ctx) { + return false + } c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) if !ok { return false @@ -150,7 +178,8 @@ func canmatch(typ int64) zero.Rule { if gid == 0 { gid = -ctx.Event.UserID } - return c.GetData(gid) == typ + d := c.GetData(gid) + return d&3 == typ && rand.Int63n(10) <= d>>59 } }