mirror of
https://github.com/42wim/matterbridge.git
synced 2025-02-07 10:04:16 +01:00
telegram: Don't try to upload empty bytes when briding URL
This commit is contained in:
parent
7e8ed3e9b8
commit
7f598e883e
@ -513,9 +513,22 @@ func (b *Btelegram) handleUploadFile(msg *config.Message, chatid int64, threadid
|
|||||||
var media []interface{}
|
var media []interface{}
|
||||||
for _, f := range msg.Extra["file"] {
|
for _, f := range msg.Extra["file"] {
|
||||||
fi := f.(config.FileInfo)
|
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{
|
file := tgbotapi.FileBytes{
|
||||||
Name: fi.Name,
|
Name: fi.Name,
|
||||||
Bytes: *fi.Data,
|
Bytes: *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.GetString("MessageFormat") == HTMLFormat {
|
if b.GetString("MessageFormat") == HTMLFormat {
|
||||||
|
Loading…
Reference in New Issue
Block a user