88 "strings"
99 "time"
1010
11- "github.com/FloatTech/AnimeAPI/bilibili "
11+ "github.com/FloatTech/AnimeAPI/setu "
1212 "github.com/FloatTech/AnimeAPI/wallet"
1313 "github.com/FloatTech/NanoBot-Plugin/utils/ctxext"
1414 "github.com/FloatTech/floatbox/file"
@@ -23,11 +23,9 @@ import (
2323)
2424
2525const (
26- backgroundURL = "https://iw233.cn/api.php?sort=pc"
27- referer = "https://weibo.com/"
28- signinMax = 1
29- // SCOREMAX 分数上限定为1200
30- SCOREMAX = 1200
26+ signinMax = 1
27+ // scoreMax 分数上限定为1200
28+ scoreMax = 1200
3129)
3230
3331var (
@@ -71,7 +69,6 @@ func init() {
7169 today := time .Now ().Format ("20060102" )
7270 // 签到图片
7371 drawedFile := cachePath + uid + today + "signin.png"
74- picFile := cachePath + uid + today + ".png"
7572 // 获取签到时间
7673 si := sdb .GetSignInByUID (int64 (uidint ))
7774 siUpdateTimeStr := si .UpdatedAt .Format ("20060102" )
@@ -105,8 +102,8 @@ func init() {
105102 }
106103 // 更新经验
107104 level := sdb .GetScoreByUID (int64 (uidint )).Score + 1
108- if level > SCOREMAX {
109- level = SCOREMAX
105+ if level > scoreMax {
106+ level = scoreMax
110107 _ , err := ctx .SendPlainMessage (true , "你的等级已经达到上限" )
111108 if err != nil {
112109 _ , _ = ctx .SendPlainMessage (false , "ERROR: " , err )
@@ -130,7 +127,6 @@ func init() {
130127 }()
131128 alldata := & scoredata {
132129 drawedfile : drawedFile ,
133- picfile : picFile ,
134130 avatarurl : ctx .Message .Author .Avatar ,
135131 inc : add ,
136132 score : wallet .GetWalletOf (int64 (uidint )),
@@ -297,24 +293,14 @@ func getrank(count int) int {
297293 return - 1
298294}
299295
300- func initPic (picFile string , avatarurl string ) (avatar []byte , err error ) {
296+ func initPic (avatarurl string ) (pic string , avatar []byte , err error ) {
301297 if avatarurl != "" {
302298 avatar , err = web .GetData (avatarurl )
303299 if err != nil {
304300 return
305301 }
306302 }
307303 defer process .SleepAbout1sTo2s ()
308- if file .IsExist (picFile ) {
309- return
310- }
311- url , err := bilibili .GetRealURL (backgroundURL )
312- if err != nil {
313- return
314- }
315- data , err := web .RequestDataWith (web .NewDefaultClient (), url , "" , referer , "" , nil )
316- if err != nil {
317- return
318- }
319- return avatar , os .WriteFile (picFile , data , 0644 )
304+ pic , err = setu .DefaultPool .Roll ("" )
305+ return
320306}
0 commit comments