diff options
author | Guillaume Lazzara <glazzara@gmail.com> | 2020-01-09 18:14:01 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2020-01-09 18:14:01 +0100 |
commit | c9d5f4c8989ddf2465a20aac46537369c654b580 (patch) | |
tree | 4d4ec88f86cd99837029e50cf6a5e29db9243c52 /bridge/telegram | |
parent | 810c15078158e221585b9a3dda819544432628f5 (diff) | |
download | matterbridge-msglm-c9d5f4c8989ddf2465a20aac46537369c654b580.tar.gz matterbridge-msglm-c9d5f4c8989ddf2465a20aac46537369c654b580.tar.bz2 matterbridge-msglm-c9d5f4c8989ddf2465a20aac46537369c654b580.zip |
Add support for WhatsApp media (jpeg/png/gif) bridging (#974)
* Whatsapp image bridging
* Prevent double message in telegram when media with caption received
Co-authored-by: imShara <shara@protonmail.com>
Diffstat (limited to 'bridge/telegram')
-rw-r--r-- | bridge/telegram/telegram.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index 33d55bcd..c7ead21f 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -8,7 +8,7 @@ import ( "github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/bridge/helper" - "github.com/go-telegram-bot-api/telegram-bot-api" + tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" ) const ( @@ -81,8 +81,8 @@ func (b *Btelegram) Send(msg config.Message) (string, error) { // Upload a file if it exists if msg.Extra != nil { for _, rmsg := range helper.HandleExtra(&msg, b.General) { - if _, err := b.sendMessage(chatid, rmsg.Username, rmsg.Text); err != nil { - b.Log.Errorf("sendMessage failed: %s", err) + if _, msgErr := b.sendMessage(chatid, rmsg.Username, rmsg.Text); msgErr != nil { + b.Log.Errorf("sendMessage failed: %s", msgErr) } } // check if we have files to upload (from slack, telegram or mattermost) @@ -97,7 +97,14 @@ func (b *Btelegram) Send(msg config.Message) (string, error) { } // Post normal message - return b.sendMessage(chatid, msg.Username, msg.Text) + // TODO: recheck it. + // Ignore empty text field needs for prevent double messages from whatsapp to telegram + // when sending media with text caption + if msg.Text != "" { + return b.sendMessage(chatid, msg.Username, msg.Text) + } + + return "", nil } func (b *Btelegram) getFileDirectURL(id string) string { |