Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve uploads between telegram and XMPP #2208

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
telegram: Add authorship caption even when file comment is empty
selfhoster1312 committed Jan 27, 2025
commit 85a46f95fd58da7e39a1789e3559b7f06bb2d2b0
16 changes: 4 additions & 12 deletions bridge/telegram/handlers.go
Original file line number Diff line number Diff line change
@@ -538,21 +538,15 @@ func (b *Btelegram) handleUploadFile(msg *config.Message, chatid int64, threadid
switch filepath.Ext(fi.Name) {
case ".jpg", ".jpe", ".png":
pc := tgbotapi.NewInputMediaPhoto(file)
if fi.Comment != "" {
pc.Caption, pc.ParseMode = TGGetParseMode(b, msg.Username, fi.Comment)
}
pc.Caption, pc.ParseMode = TGGetParseMode(b, msg.Username, fi.Comment)
media = append(media, pc)
case ".mp4", ".m4v":
vc := tgbotapi.NewInputMediaVideo(file)
if fi.Comment != "" {
vc.Caption, vc.ParseMode = TGGetParseMode(b, msg.Username, fi.Comment)
}
vc.Caption, vc.ParseMode = TGGetParseMode(b, msg.Username, fi.Comment)
media = append(media, vc)
case ".mp3", ".oga":
ac := tgbotapi.NewInputMediaAudio(file)
if fi.Comment != "" {
ac.Caption, ac.ParseMode = TGGetParseMode(b, msg.Username, fi.Comment)
}
ac.Caption, ac.ParseMode = TGGetParseMode(b, msg.Username, fi.Comment)
media = append(media, ac)
case ".ogg":
voc := tgbotapi.NewVoice(chatid, file)
@@ -565,9 +559,7 @@ func (b *Btelegram) handleUploadFile(msg *config.Message, chatid int64, threadid
return strconv.Itoa(res.MessageID), nil
default:
dc := tgbotapi.NewInputMediaDocument(file)
if fi.Comment != "" {
dc.Caption, dc.ParseMode = TGGetParseMode(b, msg.Username, fi.Comment)
}
dc.Caption, dc.ParseMode = TGGetParseMode(b, msg.Username, fi.Comment)
media = append(media, dc)
}
}