From 26a7e35f2777b8424477eef1838125a6ae55fe48 Mon Sep 17 00:00:00 2001 From: Wim Date: Wed, 27 Feb 2019 00:41:50 +0100 Subject: Add MediaConvertWebPToPNG option (telegram). (#741) * Add MediaConvertWebPToPNG option (telegram). When enabled matterbridge will convert .webp files to .png files before uploading them to the mediaserver of the other bridges. Fixes #398 --- bridge/telegram/handlers.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'bridge/telegram/handlers.go') diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go index e87466ca..93576fb4 100644 --- a/bridge/telegram/handlers.go +++ b/bridge/telegram/handlers.go @@ -245,6 +245,15 @@ func (b *Btelegram) handleDownload(rmsg *config.Message, message *tgbotapi.Messa if err != nil { return err } + if strings.HasSuffix(name, ".webp") && b.GetBool("MediaConvertWebPToPNG") { + b.Log.Debugf("WebP to PNG conversion enabled, converting %s", name) + err := helper.ConvertWebPToPNG(data) + if err != nil { + b.Log.Errorf("conversion failed: %s", err) + } else { + name = strings.Replace(name, ".webp", ".png", 1) + } + } helper.HandleDownloadData(b.Log, rmsg, name, message.Caption, "", data, b.General) return nil } -- cgit v1.2.3