Skip to content

Commit 14d8141

Browse files
author
MoeMagicMango
authored
Optimize: 更换经常出问题的iw233接口为MoeHu (#412)
1 parent 4b66783 commit 14d8141

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

plugin/score/sign_in.go

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ import (
1010
"github.com/Coloured-glaze/gg"
1111
"github.com/golang/freetype"
1212
log "github.com/sirupsen/logrus"
13-
"github.com/tidwall/gjson"
1413
"github.com/wcharczuk/go-chart/v2"
1514
zero "github.com/wdvxdr1123/ZeroBot"
1615
"github.com/wdvxdr1123/ZeroBot/message"
1716

18-
"github.com/FloatTech/floatbox/binary"
1917
"github.com/FloatTech/floatbox/file"
2018
"github.com/FloatTech/floatbox/img/writer"
21-
"github.com/FloatTech/floatbox/web"
2219
ctrl "github.com/FloatTech/zbpctrl"
2320
"github.com/FloatTech/zbputils/control"
2421
"github.com/FloatTech/zbputils/ctxext"
@@ -27,22 +24,22 @@ import (
2724
)
2825

2926
const (
30-
backgroundURL = "https://mirlkoi.ifast3.vipnps.vip/api.php?sort=pc&type=json"
31-
referer = "https://iw233.cn/main.html"
32-
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
27+
backgroundURL = "https://img.moehu.org/pic.php?id=pc"
3328
signinMax = 1
3429
// SCOREMAX 分数上限定为120
3530
SCOREMAX = 120
3631
)
3732

38-
var levelArray = [...]int{0, 1, 2, 5, 10, 20, 35, 55, 75, 100, 120}
39-
40-
func init() {
41-
engine := control.Register("score", &ctrl.Options[*zero.Ctx]{
33+
var (
34+
levelArray = [...]int{0, 1, 2, 5, 10, 20, 35, 55, 75, 100, 120}
35+
engine = control.Register("score", &ctrl.Options[*zero.Ctx]{
4236
DisableOnDefault: false,
4337
Help: "签到得分\n- 签到\n- 获得签到背景[@xxx] | 获得签到背景\n- 查看分数排名",
4438
PrivateDataFolder: "score",
4539
})
40+
)
41+
42+
func init() {
4643
cachePath := engine.DataFolder() + "cache/"
4744
go func() {
4845
_ = os.RemoveAll(cachePath)
@@ -274,14 +271,5 @@ func initPic(picFile string) error {
274271
if file.IsExist(picFile) {
275272
return nil
276273
}
277-
data, err := web.RequestDataWith(web.NewDefaultClient(), backgroundURL, "GET", referer, ua)
278-
if err != nil {
279-
return err
280-
}
281-
picURL := gjson.Get(binary.BytesToString(data), "pic.0").Str
282-
data, err = web.RequestDataWith(web.NewDefaultClient(), picURL, "GET", "", ua)
283-
if err != nil {
284-
return err
285-
}
286-
return os.WriteFile(picFile, data, 0644)
274+
return file.DownloadTo(backgroundURL, picFile, true)
287275
}

0 commit comments

Comments
 (0)