Compare commits

..

2 Commits

Author SHA1 Message Date
UserA
d179d759c9 Create gitignore 2024-08-13 00:23:05 +03:00
UserA
63186db56b Add picture caching 2024-08-13 00:22:28 +03:00
2 changed files with 9 additions and 3 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.env
**.jpg
**.db

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)