Add picture caching

This commit is contained in:
akulij 2024-08-13 00:22:28 +03:00
parent 18a15a9c79
commit 38267c3ff2

View File

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