summaryrefslogtreecommitdiffstats
path: root/bridge/telegram/telegram.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-11-13 00:20:31 +0100
committerWim <wim@42.be>2017-11-13 00:20:31 +0100
commit36a800c3f57ed1880ed6530db0542c979f6c69e7 (patch)
tree045b287bd5087558e3756f870a4336061490ef60 /bridge/telegram/telegram.go
parent6d21f84187cddf17a2758a57bc77c37ed9e7ba70 (diff)
downloadmatterbridge-msglm-36a800c3f57ed1880ed6530db0542c979f6c69e7.tar.gz
matterbridge-msglm-36a800c3f57ed1880ed6530db0542c979f6c69e7.tar.bz2
matterbridge-msglm-36a800c3f57ed1880ed6530db0542c979f6c69e7.zip
Add support for comments from slack file uploads (slack)
Diffstat (limited to 'bridge/telegram/telegram.go')
-rw-r--r--bridge/telegram/telegram.go28
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
+}