Reportar errores en vez de mandar videos rotos
This commit is contained in:
parent
209538d6fb
commit
25532e07f6
2 changed files with 10 additions and 0 deletions
9
main.go
9
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
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue