✏️ 修正zip缓存位置

This commit is contained in:
fumiama 2021-10-15 15:27:19 +08:00
parent fa6d14d89a
commit c183c4f17d

View File

@ -15,6 +15,7 @@ import (
"time" "time"
"github.com/fogleman/gg" "github.com/fogleman/gg"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot" zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message" "github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper" "github.com/wdvxdr1123/ZeroBot/utils/helper"
@ -102,6 +103,7 @@ func init() {
// 个人用户设为负数 // 个人用户设为负数
gid = -ctx.Event.UserID gid = -ctx.Event.UserID
} }
logrus.Debugln("[fortune]gid:", ctx.Event.GroupID, "uid:", ctx.Event.UserID)
if v, ok := conf.Kind[gid]; ok { if v, ok := conf.Kind[gid]; ok {
kind = table[v] kind = table[v]
} }
@ -109,21 +111,22 @@ func init() {
folder := base + kind folder := base + kind
if _, err := os.Stat(folder); err != nil && !os.IsExist(err) { if _, err := os.Stat(folder); err != nil && !os.IsExist(err) {
ctx.SendChain(message.Text("正在下载背景图片,请稍后...")) ctx.SendChain(message.Text("正在下载背景图片,请稍后..."))
zipfile := folder + ".zip" zipfile := kind + ".zip"
err := dl.DownloadTo(site+zipfile, zipfile) zipcache := base + zipfile
err := dl.DownloadTo(site+zipfile, zipcache)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR: ", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
ctx.SendChain(message.Text("下载背景图片完毕")) ctx.SendChain(message.Text("下载背景图片完毕"))
err = unpack(zipfile, folder+"/") err = unpack(zipcache, folder+"/")
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR: ", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
ctx.SendChain(message.Text("解压背景图片完毕")) ctx.SendChain(message.Text("解压背景图片完毕"))
// 释放空间 // 释放空间
os.Remove(zipfile) os.Remove(zipcache)
} }
// 生成种子 // 生成种子
t, _ := strconv.ParseInt(time.Now().Format("20060102"), 10, 64) t, _ := strconv.ParseInt(time.Now().Format("20060102"), 10, 64)