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