Reportar errores en vez de mandar videos rotos

This commit is contained in:
Cat /dev/Nulo 2022-08-27 19:50:55 -03:00
parent 209538d6fb
commit 25532e07f6
2 changed files with 10 additions and 0 deletions

View file

@ -16,6 +16,7 @@ func respondWith(msg *tgbotapi.Message, str string) tgbotapi.MessageConfig {
res := tgbotapi.NewMessage(msg.Chat.ID, str) res := tgbotapi.NewMessage(msg.Chat.ID, str)
res.ReplyToMessageID = msg.MessageID res.ReplyToMessageID = msg.MessageID
res.DisableWebPagePreview = true res.DisableWebPagePreview = true
res.ParseMode = "markdown"
return res return res
} }
@ -72,6 +73,14 @@ func handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update) {
continue continue
} }
log.Println(lookup) log.Println(lookup)
if !lookup.Success {
if len(lookup.Message) > 0 {
bot.Send(respondWithMany(msg, "Hubo un error al descargar ", urlString, ": `", lookup.Message, "`"))
} else {
bot.Send(respondWithMany(msg, "Hubo un error al descargar ", urlString, "."))
}
continue
}
res := tgbotapi.NewVideo(msg.Chat.ID, *lookup) res := tgbotapi.NewVideo(msg.Chat.ID, *lookup)
res.ReplyToMessageID = msg.MessageID res.ReplyToMessageID = msg.MessageID

View file

@ -18,6 +18,7 @@ type LookupResponse struct {
LikeCount int `json:"like_count"` LikeCount int `json:"like_count"`
ShareCount int `json:"share_count"` ShareCount int `json:"share_count"`
Success bool `json:"success"` Success bool `json:"success"`
Message string `json:"message"`
Token string `json:"token"` Token string `json:"token"`
} }