diff options
Diffstat (limited to 'bridge/telegram/telegram.go')
-rw-r--r-- | bridge/telegram/telegram.go | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index f4662669..5cd49253 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -114,20 +114,14 @@ func (b *Btelegram) Send(msg config.Message) (string, error) { if err != nil { log.Errorf("file upload failed: %#v", err) } + if fi.Comment != "" { + b.sendMessage(chatid, msg.Username+fi.Comment) + } } + return "", nil } } - - m := tgbotapi.NewMessage(chatid, msg.Username+msg.Text) - if b.Config.MessageFormat == "HTML" { - m.ParseMode = tgbotapi.ModeHTML - } - res, err := b.c.Send(m) - if err != nil { - return "", err - } - return strconv.Itoa(res.MessageID), nil - + return b.sendMessage(chatid, msg.Username+msg.Text) } func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) { @@ -275,3 +269,15 @@ func (b *Btelegram) handleDownload(file interface{}, msg *config.Message) { } } } + +func (b *Btelegram) sendMessage(chatid int64, text string) (string, error) { + m := tgbotapi.NewMessage(chatid, text) + if b.Config.MessageFormat == "HTML" { + m.ParseMode = tgbotapi.ModeHTML + } + res, err := b.c.Send(m) + if err != nil { + return "", err + } + return strconv.Itoa(res.MessageID), nil +} |