Add picture caching

This commit is contained in:
UserA 2024-08-13 00:22:28 +03:00
parent 6bc45babc5
commit 63186db56b

View File

@ -139,9 +139,12 @@ func main() {
msg.ReplyMarkup = kbd msg.ReplyMarkup = kbd
bc.bot.Send(msg) bc.bot.Send(msg)
} else { } else {
url, _ := bc.bot.GetFileDirectURL(img) filename := "./" + img + ".jpg"
DownloadFile("./preview.jpg", url) if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
msg := tgbotapi.NewPhoto(update.Message.Chat.ID, tgbotapi.FilePath("./preview.jpg")) url, _ := bc.bot.GetFileDirectURL(img)
DownloadFile(filename, url)
}
msg := tgbotapi.NewPhoto(update.Message.Chat.ID, tgbotapi.FilePath(filename))
msg.Caption = bc.GetBotContent("start") msg.Caption = bc.GetBotContent("start")
msg.ReplyMarkup = kbd msg.ReplyMarkup = kbd
bc.bot.Send(msg) bc.bot.Send(msg)