fix: 更新图片下载逻辑,移除临时文件删除操作并直接使用封面图片路径
This commit is contained in:
parent
7ba0f74b49
commit
6ddb3574d0
@ -2,7 +2,6 @@ package beatleader
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
@ -178,13 +177,12 @@ func getMyRecentScore(msg model.Message) (reply *model.Reply) {
|
||||
wg.Add(1)
|
||||
go func(songHash string) {
|
||||
defer wg.Done()
|
||||
filePath, err := util.DownloadFile(coverImageMap[songHash], "/tmp/qqbot", true)
|
||||
filePath, err := util.DownloadFile(coverImageMap[songHash], constants.TempDir, true)
|
||||
if err != nil {
|
||||
log.Printf("下载图片失败: %v", err)
|
||||
return
|
||||
}
|
||||
newPath, err := util.ResizeImageByMaxHeight(filePath, 20)
|
||||
os.Remove(filePath)
|
||||
if err != nil {
|
||||
log.Printf("缩放图片失败: %v", err)
|
||||
}
|
||||
@ -196,7 +194,7 @@ func getMyRecentScore(msg model.Message) (reply *model.Reply) {
|
||||
imageMsg := message.ImageMessage{
|
||||
Type: "image",
|
||||
Data: message.ImageMessageData{
|
||||
File: util.GetResizedIamgePathByOrgPath(util.GenTempFilePath(record.SongHash + ".jpeg")),
|
||||
File: coverImageMap[record.SongHash],
|
||||
},
|
||||
}
|
||||
scoreMsg += imageMsg.ToCQString() + record.ToString() + "\n"
|
||||
|
@ -210,9 +210,6 @@ func getMyRecentScore(msg model.Message) (reply *model.Reply) {
|
||||
go func(songHash string) {
|
||||
defer wg.Done()
|
||||
//文件存在则跳过
|
||||
// if _, err := os.Stat(util.GetResizedIamgePathByOrgPath(util.GenTempFilePath(songHash + ".jpeg"))); err == nil {
|
||||
// return
|
||||
// }
|
||||
filePath, err := util.DownloadFile(coverImageMap[songHash], constants.TempDir, true)
|
||||
if err != nil {
|
||||
log.Printf("下载图片失败: %v", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user