@@ -13,6 +13,7 @@ import (
1313 sql "github.com/FloatTech/sqlite"
1414 control "github.com/FloatTech/zbputils/control"
1515 "github.com/FloatTech/zbputils/ctxext"
16+ "github.com/FloatTech/zbputils/file"
1617 fileutil "github.com/FloatTech/zbputils/file"
1718 imagepool "github.com/FloatTech/zbputils/img/pool"
1819 "github.com/FloatTech/zbputils/math"
@@ -156,21 +157,28 @@ func (p *imgpool) push(ctx *zero.Ctx, imgtype string, illust *pixiv.Illust) {
156157 n := u [strings .LastIndex (u , "/" )+ 1 : len (u )- 4 ]
157158 m , err := imagepool .GetImage (n )
158159 var msg message.MessageSegment
160+ f := fileutil .BOTPATH + "/" + illust .Path (0 )
159161 if err != nil {
160162 // 下载图片
161- f := ""
162- if f , err = illust .DownloadToCache (0 , n ); err != nil {
163+ if err = illust .DownloadToCache (0 ); err != nil {
163164 ctx .SendChain (message .Text ("ERROR: " , err ))
164165 return
165166 }
166- f = fileutil .BOTPATH + "/" + f
167167 m .SetFile (f )
168168 _ , _ = m .Push (ctxext .SendToSelf (ctx ), ctxext .GetMessage (ctx ))
169169 msg = message .Image ("file:///" + f )
170170 } else {
171171 msg = message .Image (m .String ())
172172 if ctxext .SendToSelf (ctx )(msg ) == 0 {
173173 msg = msg .Add ("cache" , "0" )
174+ if ctxext .SendToSelf (ctx )(msg ) == 0 {
175+ err = file .DownloadTo (m .String (), f , true )
176+ if err != nil {
177+ ctx .SendChain (message .Text ("ERROR: " , err ))
178+ return
179+ }
180+ msg = message .Image ("file:///" + f )
181+ }
174182 }
175183 }
176184 p .poolmu .Lock ()
@@ -235,7 +243,7 @@ func (p *imgpool) add(ctx *zero.Ctx, imgtype string, id int64) error {
235243 return err
236244 }
237245 // 下载插画
238- if _ , err := illust .DownloadToCache (0 , strconv . FormatInt ( id , 10 ) + "_p0" ); err != nil {
246+ if err := illust .DownloadToCache (0 ); err != nil {
239247 return err
240248 }
241249 // 发送到发送者
0 commit comments