mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-15 08:29:25 +01:00
Add more debug info (telegram)
This commit is contained in:
parent
13d081ea80
commit
64c542e614
@ -227,28 +227,33 @@ func (b *Btelegram) handleDownload(file interface{}, msg *config.Message) {
|
|||||||
url := ""
|
url := ""
|
||||||
name := ""
|
name := ""
|
||||||
text := ""
|
text := ""
|
||||||
|
fileid := ""
|
||||||
switch v := file.(type) {
|
switch v := file.(type) {
|
||||||
case *tgbotapi.Sticker:
|
case *tgbotapi.Sticker:
|
||||||
size = v.FileSize
|
size = v.FileSize
|
||||||
url = b.getFileDirectURL(v.FileID)
|
url = b.getFileDirectURL(v.FileID)
|
||||||
name = "sticker"
|
name = "sticker"
|
||||||
text = " " + url
|
text = " " + url
|
||||||
|
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"
|
name = "video"
|
||||||
text = " " + url
|
text = " " + url
|
||||||
|
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"
|
name = "photo"
|
||||||
text = " " + url
|
text = " " + url
|
||||||
|
fileid = v.FileID
|
||||||
case *tgbotapi.Document:
|
case *tgbotapi.Document:
|
||||||
size = v.FileSize
|
size = v.FileSize
|
||||||
url = b.getFileDirectURL(v.FileID)
|
url = b.getFileDirectURL(v.FileID)
|
||||||
name = v.FileName
|
name = v.FileName
|
||||||
text = " " + v.FileName + " : " + url
|
text = " " + v.FileName + " : " + url
|
||||||
|
fileid = v.FileID
|
||||||
}
|
}
|
||||||
if b.Config.UseInsecureURL {
|
if b.Config.UseInsecureURL {
|
||||||
msg.Text = text
|
msg.Text = text
|
||||||
@ -256,11 +261,13 @@ func (b *Btelegram) handleDownload(file interface{}, msg *config.Message) {
|
|||||||
}
|
}
|
||||||
// if we have a file attached, download it (in memory) and put a pointer to it in msg.Extra
|
// if we have a file attached, download it (in memory) and put a pointer to it in msg.Extra
|
||||||
// limit to 1MB for now
|
// limit to 1MB for now
|
||||||
|
flog.Debugf("trying to download %#v fileid %#v with size %#v", name, fileid, size)
|
||||||
if size <= 1000000 {
|
if size <= 1000000 {
|
||||||
data, err := helper.DownloadFile(url)
|
data, err := helper.DownloadFile(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
flog.Errorf("download %s failed %#v", url, err)
|
flog.Errorf("download %s failed %#v", url, err)
|
||||||
} else {
|
} else {
|
||||||
|
flog.Debugf("download OK %#v %#v %#v", name, len(data), len(url))
|
||||||
msg.Extra["file"] = append(msg.Extra["file"], config.FileInfo{Name: name, Data: data})
|
msg.Extra["file"] = append(msg.Extra["file"], config.FileInfo{Name: name, Data: data})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user