diff --git a/README.md b/README.md index 204c1c29..6ff49c41 100644 --- a/README.md +++ b/README.md @@ -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"` diff --git a/plugin_ai_false/ai_false.go b/plugin_ai_false/ai_false.go index 8c4aca91..efbc9df2 100644 --- a/plugin_ai_false/ai_false.go +++ b/plugin_ai_false/ai_false.go @@ -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 { diff --git a/plugin_setutime/setu_geter.go b/plugin_setutime/setu_geter.go index 564e3d70..6f126d6c 100644 --- a/plugin_setutime/setu_geter.go +++ b/plugin_setutime/setu_geter.go @@ -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)