telegram: Don't try to upload empty bytes when briding URL

This commit is contained in:
selfhoster1312 2025-01-27 12:25:21 +01:00
parent 7e8ed3e9b8
commit 7f598e883e

View File

@ -513,9 +513,22 @@ func (b *Btelegram) handleUploadFile(msg *config.Message, chatid int64, threadid
var media []interface{}
for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo)
// If the file is only a URL, download it first
data := fi.Data
if data == nil {
data2, err := helper.DownloadFile(fi.URL)
if err != nil {
b.Log.Errorf("Failed to download file %s: %s", fi.URL, err)
continue
}
data = data2
}
file := tgbotapi.FileBytes{
Name: fi.Name,
Bytes: *fi.Data,
Bytes: *data,
}
if b.GetString("MessageFormat") == HTMLFormat {