Skip to content

Commit

Permalink
telegram: Add authorship caption even when file comment is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
selfhoster1312 committed Jan 27, 2025
1 parent 5b73a5d commit 85a46f9
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions bridge/telegram/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
}
Expand Down

0 comments on commit 85a46f9

Please sign in to comment.