From 25532e07f6229bd98c5214145a79e1e596769f77 Mon Sep 17 00:00:00 2001 From: Nulo Date: Sat, 27 Aug 2022 19:50:55 -0300 Subject: [PATCH] Reportar errores en vez de mandar videos rotos --- main.go | 9 +++++++++ tikmate.go | 1 + 2 files changed, 10 insertions(+) diff --git a/main.go b/main.go index 784a06f..0de5a75 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,7 @@ func respondWith(msg *tgbotapi.Message, str string) tgbotapi.MessageConfig { res := tgbotapi.NewMessage(msg.Chat.ID, str) res.ReplyToMessageID = msg.MessageID res.DisableWebPagePreview = true + res.ParseMode = "markdown" return res } @@ -72,6 +73,14 @@ func handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update) { continue } 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.ReplyToMessageID = msg.MessageID diff --git a/tikmate.go b/tikmate.go index b0bcb8f..7ccf707 100644 --- a/tikmate.go +++ b/tikmate.go @@ -18,6 +18,7 @@ type LookupResponse struct { LikeCount int `json:"like_count"` ShareCount int `json:"share_count"` Success bool `json:"success"` + Message string `json:"message"` Token string `json:"token"` }