diff options
author | Wim <wim@42.be> | 2017-07-30 17:48:23 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-07-30 17:48:23 +0200 |
commit | f8e6a69d6e8453de0b700b6e9a3eedeec0b1f0a5 (patch) | |
tree | 7ac1bc3a4c0d0429cf01adcedd2ae0422d6963cd /bridge/mattermost/mattermost.go | |
parent | 54216cec4b4f2023306e378587b1ac55dc720968 (diff) | |
download | matterbridge-msglm-f8e6a69d6e8453de0b700b6e9a3eedeec0b1f0a5.tar.gz matterbridge-msglm-f8e6a69d6e8453de0b700b6e9a3eedeec0b1f0a5.tar.bz2 matterbridge-msglm-f8e6a69d6e8453de0b700b6e9a3eedeec0b1f0a5.zip |
Add action support for slack,mattermost,irc,gitter,matrix,xmpp,discord. #199
Diffstat (limited to 'bridge/mattermost/mattermost.go')
-rw-r--r-- | bridge/mattermost/mattermost.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 67dc7b5b..7e3e7e2e 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -6,6 +6,7 @@ import ( "github.com/42wim/matterbridge/matterclient" "github.com/42wim/matterbridge/matterhook" log "github.com/Sirupsen/logrus" + "strings" ) type MMhook struct { @@ -117,6 +118,9 @@ func (b *Bmattermost) JoinChannel(channel string) error { func (b *Bmattermost) Send(msg config.Message) error { flog.Debugf("Receiving %#v", msg) + if msg.Event == config.EVENT_USER_ACTION { + msg.Text = "*" + msg.Text + "*" + } nick := msg.Username message := msg.Text channel := msg.Channel @@ -152,8 +156,14 @@ func (b *Bmattermost) handleMatter() { go b.handleMatterClient(mchan) } for message := range mchan { + rmsg := config.Message{Username: message.Username, Channel: message.Channel, Account: b.Account, UserID: message.UserID} + text, ok := b.replaceAction(message.Text) + if ok { + rmsg.Event = config.EVENT_USER_ACTION + } + rmsg.Text = text flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account) - b.Remote <- config.Message{Text: message.Text, Username: message.Username, Channel: message.Channel, Account: b.Account, UserID: message.UserID} + b.Remote <- rmsg } } @@ -226,3 +236,10 @@ func (b *Bmattermost) apiLogin() error { go b.mc.StatusLoop() return nil } + +func (b *Bmattermost) replaceAction(text string) (string, bool) { + if strings.HasPrefix(text, "*") && strings.HasSuffix(text, "*") { + return strings.Replace(text, "*", "", -1), true + } + return text, false +} |