From 9691d8ac43f13b53d72bc54f4e001436e5f91531 Mon Sep 17 00:00:00 2001 From: Manuel Raimo Date: Sun, 24 Sep 2023 12:06:42 +0200 Subject: [PATCH] fix: handle yt-dlp errors --- events.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/events.go b/events.go index 6cf57ce..69f2550 100644 --- a/events.go +++ b/events.go @@ -15,12 +15,8 @@ func videoDownload(c tele.Context) error { filename, hit := checkAndDownload(url) err := c.Reply(cache[filename], tele.Silent) - if err != nil { - lit.Error(err.Error()) - } - - if !hit { - save(cache[filename]) + if err == nil && !hit { + go save(cache[filename]) } } else { // For twitter, we send the same url with only fx appended to it @@ -48,7 +44,10 @@ func inlineQuery(c tele.Context) error { filename, hit := checkAndDownload(text) // Upload video to channel, so we can send it even in inline mode - _, _ = c.Bot().Send(tele.ChatID(cfg.Channel), cache[filename]) + _, err := c.Bot().Send(tele.ChatID(cfg.Channel), cache[filename]) + if err != nil { + return err + } if !hit { go save(cache[filename])