优化代码结构 (#565)

This commit is contained in:
DreamZero
2023-01-30 17:42:53 +08:00
committed by GitHub
parent 07e6f33b04
commit f96b5f8965
11 changed files with 73 additions and 48 deletions

View File

@@ -10,9 +10,12 @@ import (
"time"
"github.com/Coloured-glaze/gg"
"github.com/FloatTech/AnimeAPI/bilibili"
"github.com/FloatTech/AnimeAPI/wallet"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/img/writer"
"github.com/FloatTech/floatbox/process"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
@@ -23,13 +26,11 @@ import (
"github.com/wcharczuk/go-chart/v2"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
// 货币系统
"github.com/FloatTech/AnimeAPI/wallet"
)
const (
backgroundURL = "https://img.moehu.org/pic.php?id=pc"
backgroundURL = "https://iw233.cn/api.php?sort=pc"
referer = "https://weibo.com/"
signinMax = 1
// SCOREMAX 分数上限定为1200
SCOREMAX = 1200
@@ -307,5 +308,13 @@ func initPic(picFile string) error {
return nil
}
defer process.SleepAbout1sTo2s()
return file.DownloadTo(backgroundURL, picFile)
url, err := bilibili.GetRealURL(backgroundURL)
if err != nil {
return err
}
data, err := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil)
if err != nil {
return err
}
return os.WriteFile(picFile, data, 0644)
}