Reuse existing image instead of uploading every time new

This commit is contained in:
akulij 2024-08-13 03:15:59 +03:00
parent 5e23b05631
commit 88980bb81c

View File

@ -145,12 +145,7 @@ func ProcessUpdate(bc BotController, update tgbotapi.Update) {
msg.ReplyMarkup = kbd msg.ReplyMarkup = kbd
bc.bot.Send(msg) bc.bot.Send(msg)
} else { } else {
filename := "./" + img + ".jpg" msg := tgbotapi.NewPhoto(update.Message.Chat.ID, tgbotapi.FileID(img))
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
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)