From dc899f55fe74a1db69c5764373788fae61d0133d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 17 Feb 2025 23:38:21 +0900 Subject: [PATCH] fix(aichat): load noreplyat --- plugin/aichat/main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go index 6b67069f..500dbcc3 100644 --- a/plugin/aichat/main.go +++ b/plugin/aichat/main.go @@ -50,6 +50,7 @@ func init() { mf := en.DataFolder() + "model.txt" sf := en.DataFolder() + "system.txt" pf := en.DataFolder() + "sep.txt" + nf := en.DataFolder() + "NoReplyAT" if file.IsExist(mf) { data, err := os.ReadFile(mf) if err != nil { @@ -74,6 +75,7 @@ func init() { sepstr = string(data) } } + noreplyat = file.IsExist(nf) en.OnMessage(func(ctx *zero.Ctx) bool { return ctx.ExtractPlainText() != "" && (!noreplyat || (noreplyat && !ctx.Event.IsToMe)) @@ -275,9 +277,8 @@ func init() { en.OnRegex("^设置AI聊天(不)?响应AT$", zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { args := ctx.State["regex_matched"].([]string) isno := args[1] == "不" - fp := en.DataFolder() + "NoReplyAT" if isno { - f, err := os.Create(fp) + f, err := os.Create(nf) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return @@ -290,7 +291,7 @@ func init() { } noreplyat = true } else { - _ = os.Remove(fp) + _ = os.Remove(nf) noreplyat = false } ctx.SendChain(message.Text("成功"))