From 151a5d480f07df5e50ada0193f6bf9edcde38777 Mon Sep 17 00:00:00 2001 From: MoeMagicMango Date: Sat, 21 May 2022 22:53:20 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E6=9B=B4=E6=8D=A2=E7=A8=B3=E5=AE=9A?= =?UTF-8?q?=E7=9A=84=E8=83=8C=E6=99=AFapi=20+=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=9B=A0api=E9=97=AE=E9=A2=98=E7=AD=BE=E5=88=B0=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=97=A0=E6=B3=95=E5=87=BA=E7=8E=B0=E4=BD=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E5=B7=B2=E7=BB=8F=E8=AE=B0=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#236)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 通过修改顺序解决签到背景API出问题 * Update sign_in.go * 🎨 改进代码样式 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- plugin/score/sign_in.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/plugin/score/sign_in.go b/plugin/score/sign_in.go index c67b75e9..60b8e452 100644 --- a/plugin/score/sign_in.go +++ b/plugin/score/sign_in.go @@ -24,7 +24,7 @@ import ( ) const ( - backgroundURL = "https://iw233.cn/api.php?sort=pc&type=json" + backgroundURL = "https://mirlkoi.ifast3.vipnps.vip/api.php?sort=pc&type=json" referer = "https://iw233.cn/main.html" ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36" signinMax = 1 @@ -56,11 +56,10 @@ func init() { today := now.Format("20060102") si := sdb.GetSignInByUID(uid) siUpdateTimeStr := si.UpdatedAt.Format("20060102") - if siUpdateTimeStr != today { - _ = sdb.InsertOrUpdateSignInCountByUID(uid, 0) - } - drawedFile := cachePath + strconv.FormatInt(uid, 10) + today + "signin.png" + + picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png" + if si.Count >= signinMax && siUpdateTimeStr == today { ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("今天你已经签到过了!")) if file.IsExist(drawedFile) { @@ -68,21 +67,21 @@ func init() { } return } - - picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png" err := initPic(picFile) if err != nil { ctx.SendChain(message.Text("ERROR:", err)) return } - - _ = sdb.InsertOrUpdateSignInCountByUID(uid, si.Count+1) - back, err := gg.LoadImage(picFile) if err != nil { ctx.SendChain(message.Text("ERROR:", err)) return } + if siUpdateTimeStr != today { + _ = sdb.InsertOrUpdateSignInCountByUID(uid, 0) + } + + _ = sdb.InsertOrUpdateSignInCountByUID(uid, si.Count+1) // 避免图片过大,最大 1280*720 back = img.Limit(back, 1280, 720)