aifalse 增加 清理缓存

This commit is contained in:
fumiama 2021-09-27 21:51:05 +08:00
parent 4df30a56a3
commit 1d469a40d5
3 changed files with 13 additions and 0 deletions

View File

@ -114,6 +114,7 @@
- [x] [回复]查重
- **AIfalse** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false"`
- [x] 查询计算机当前活跃度 [身体检查]
- [x] 清理缓存
- [ ] 简易语音
- [ ] 爬图合成 [@xxx]
- **minecraft** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft"`

View File

@ -3,6 +3,7 @@ package aifalse
import (
"math"
"os"
"time"
"github.com/shirou/gopsutil/cpu"
@ -30,6 +31,15 @@ func init() { // 插件主体
),
)
})
engine.OnFullMatch("清理缓存", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
err := os.RemoveAll("data/cache/*")
if err != nil {
ctx.Send("错误: " + err.Error())
} else {
ctx.Send("成功!")
}
})
}
func cpuPercent() float64 {

View File

@ -48,6 +48,8 @@ func newPools() *imgpool {
Pool: map[string][]*pixiv.Illust{},
Form: 0,
}
// 每次启动清理缓存
os.RemoveAll(cache.Path)
err := os.MkdirAll(cache.Path, 0755)
if err != nil {
panic(err)