mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 05:30:07 +08:00
fix(aichat): load noreplyat
This commit is contained in:
parent
8c11f48502
commit
dc899f55fe
@ -50,6 +50,7 @@ func init() {
|
|||||||
mf := en.DataFolder() + "model.txt"
|
mf := en.DataFolder() + "model.txt"
|
||||||
sf := en.DataFolder() + "system.txt"
|
sf := en.DataFolder() + "system.txt"
|
||||||
pf := en.DataFolder() + "sep.txt"
|
pf := en.DataFolder() + "sep.txt"
|
||||||
|
nf := en.DataFolder() + "NoReplyAT"
|
||||||
if file.IsExist(mf) {
|
if file.IsExist(mf) {
|
||||||
data, err := os.ReadFile(mf)
|
data, err := os.ReadFile(mf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -74,6 +75,7 @@ func init() {
|
|||||||
sepstr = string(data)
|
sepstr = string(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
noreplyat = file.IsExist(nf)
|
||||||
|
|
||||||
en.OnMessage(func(ctx *zero.Ctx) bool {
|
en.OnMessage(func(ctx *zero.Ctx) bool {
|
||||||
return ctx.ExtractPlainText() != "" && (!noreplyat || (noreplyat && !ctx.Event.IsToMe))
|
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) {
|
en.OnRegex("^设置AI聊天(不)?响应AT$", zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||||
args := ctx.State["regex_matched"].([]string)
|
args := ctx.State["regex_matched"].([]string)
|
||||||
isno := args[1] == "不"
|
isno := args[1] == "不"
|
||||||
fp := en.DataFolder() + "NoReplyAT"
|
|
||||||
if isno {
|
if isno {
|
||||||
f, err := os.Create(fp)
|
f, err := os.Create(nf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
@ -290,7 +291,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
noreplyat = true
|
noreplyat = true
|
||||||
} else {
|
} else {
|
||||||
_ = os.Remove(fp)
|
_ = os.Remove(nf)
|
||||||
noreplyat = false
|
noreplyat = false
|
||||||
}
|
}
|
||||||
ctx.SendChain(message.Text("成功"))
|
ctx.SendChain(message.Text("成功"))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user