5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-26 10:02:06 +00:00

Add extension to sticker/video/photo (telegram)

This commit is contained in:
Wim 2017-11-12 22:04:35 +01:00
parent f1e9833310
commit 6d21f84187

View File

@ -3,6 +3,7 @@ package btelegram
import ( import (
"regexp" "regexp"
"strconv" "strconv"
"strings"
"github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper" "github.com/42wim/matterbridge/bridge/helper"
@ -232,20 +233,23 @@ func (b *Btelegram) handleDownload(file interface{}, msg *config.Message) {
case *tgbotapi.Sticker: case *tgbotapi.Sticker:
size = v.FileSize size = v.FileSize
url = b.getFileDirectURL(v.FileID) url = b.getFileDirectURL(v.FileID)
name = "sticker" urlPart := strings.Split(url, "/")
name = urlPart[len(urlPart)-1]
text = " " + url text = " " + url
fileid = v.FileID fileid = v.FileID
case *tgbotapi.Video: case *tgbotapi.Video:
size = v.FileSize size = v.FileSize
url = b.getFileDirectURL(v.FileID) url = b.getFileDirectURL(v.FileID)
name = "video" urlPart := strings.Split(url, "/")
name = urlPart[len(urlPart)-1]
text = " " + url text = " " + url
fileid = v.FileID fileid = v.FileID
case *[]tgbotapi.PhotoSize: case *[]tgbotapi.PhotoSize:
photos := *v photos := *v
size = photos[len(photos)-1].FileSize size = photos[len(photos)-1].FileSize
url = b.getFileDirectURL(photos[len(photos)-1].FileID) url = b.getFileDirectURL(photos[len(photos)-1].FileID)
name = "photo" urlPart := strings.Split(url, "/")
name = urlPart[len(urlPart)-1]
text = " " + url text = " " + url
case *tgbotapi.Document: case *tgbotapi.Document:
size = v.FileSize size = v.FileSize