fallar si no es 200

This commit is contained in:
Cat /dev/Nulo 2023-05-16 23:33:40 -03:00
parent ef658e4641
commit ac0a1827c1

View file

@ -8,6 +8,7 @@ import (
"os" "os"
"strings" "strings"
"unicode/utf16" "unicode/utf16"
"errors"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"nulo.in/dlbot/common" "nulo.in/dlbot/common"
@ -30,6 +31,9 @@ func (fu FileURL) UploadData() (string, io.Reader, error) {
if err != nil { if err != nil {
return "", nil, err return "", nil, err
} }
if res.StatusCode != http.StatusOK {
return "", nil, errors.New(res.Status)
}
return "url.mp4", res.Body, nil return "url.mp4", res.Body, nil
} }
@ -90,6 +94,7 @@ func (config Config) handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update)
_, err := bot.Send(res) _, err := bot.Send(res)
if err != nil { if err != nil {
log.Println("Error subiendo", url.String(), err) log.Println("Error subiendo", url.String(), err)
bot.Send(respondWithMany(update.Message, "Hubo un error al descargar ", url.String(), "."))
} }
} }