summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-12-10 15:08:23 +0100
committerWim <wim@42.be>2017-12-10 15:08:23 +0100
commitfa2076111093de02b6d724477afce629528db3f1 (patch)
tree9ea671598a9e971093c52b9420b2ce5ab5578f46
parente4a0e0a0e950599be49a88ec254b4bfad0779cf4 (diff)
downloadmatterbridge-msglm-fa2076111093de02b6d724477afce629528db3f1.tar.gz
matterbridge-msglm-fa2076111093de02b6d724477afce629528db3f1.tar.bz2
matterbridge-msglm-fa2076111093de02b6d724477afce629528db3f1.zip
Add support for Audio/Voice files (telegram). Closes #314
-rw-r--r--bridge/telegram/telegram.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go
index c2f69c3d..328850ea 100644
--- a/bridge/telegram/telegram.go
+++ b/bridge/telegram/telegram.go
@@ -179,6 +179,12 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {
if message.Document != nil {
b.handleDownload(message.Document, &fmsg)
}
+ if message.Voice != nil {
+ b.handleDownload(message.Voice, &fmsg)
+ }
+ if message.Audio != nil {
+ b.handleDownload(message.Audio, &fmsg)
+ }
if message.ForwardFrom != nil {
text = "Forward from " + message.ForwardFrom.FirstName
@@ -242,6 +248,23 @@ func (b *Btelegram) handleDownload(file interface{}, msg *config.Message) {
text := ""
fileid := ""
switch v := file.(type) {
+ case *tgbotapi.Audio:
+ size = v.FileSize
+ url = b.getFileDirectURL(v.FileID)
+ urlPart := strings.Split(url, "/")
+ name = urlPart[len(urlPart)-1]
+ text = " " + url
+ fileid = v.FileID
+ case *tgbotapi.Voice:
+ size = v.FileSize
+ url = b.getFileDirectURL(v.FileID)
+ urlPart := strings.Split(url, "/")
+ name = urlPart[len(urlPart)-1]
+ text = " " + url
+ if !strings.HasSuffix(name, ".ogg") {
+ name = name + ".ogg"
+ }
+ fileid = v.FileID
case *tgbotapi.Sticker:
size = v.FileSize
url = b.getFileDirectURL(v.FileID)