From 36a800c3f57ed1880ed6530db0542c979f6c69e7 Mon Sep 17 00:00:00 2001 From: Wim Date: Mon, 13 Nov 2017 00:20:31 +0100 Subject: Add support for comments from slack file uploads (slack) --- bridge/telegram/telegram.go | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'bridge/telegram') 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 +} -- cgit v1.2.3