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/matrix | |
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/matrix')
-rw-r--r-- | bridge/matrix/matrix.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 2fd91b32..06359855 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -78,6 +78,11 @@ func (b *Bmatrix) Send(msg config.Message) error { flog.Debugf("Receiving %#v", msg) channel := b.getRoomID(msg.Channel) flog.Debugf("Sending to channel %s", channel) + if msg.Event == config.EVENT_USER_ACTION { + b.mc.SendMessageEvent(channel, "m.room.message", + matrix.TextMessage{"m.emote", msg.Username + msg.Text}) + return nil + } b.mc.SendText(channel, msg.Username+msg.Text) return nil } @@ -95,7 +100,7 @@ func (b *Bmatrix) getRoomID(channel string) string { func (b *Bmatrix) handlematrix() error { syncer := b.mc.Syncer.(*matrix.DefaultSyncer) syncer.OnEventType("m.room.message", func(ev *matrix.Event) { - if ev.Content["msgtype"].(string) == "m.text" && ev.Sender != b.UserID { + if (ev.Content["msgtype"].(string) == "m.text" || ev.Content["msgtype"].(string) == "m.emote") && ev.Sender != b.UserID { b.RLock() channel, ok := b.RoomMap[ev.RoomID] b.RUnlock() @@ -108,8 +113,12 @@ func (b *Bmatrix) handlematrix() error { re := regexp.MustCompile("(.*?):.*") username = re.ReplaceAllString(username, `$1`) } + rmsg := config.Message{Username: username, Text: ev.Content["body"].(string), Channel: channel, Account: b.Account, UserID: ev.Sender} + if ev.Content["msgtype"].(string) == "m.emote" { + rmsg.Event = config.EVENT_USER_ACTION + } flog.Debugf("Sending message from %s on %s to gateway", ev.Sender, b.Account) - b.Remote <- config.Message{Username: username, Text: ev.Content["body"].(string), Channel: channel, Account: b.Account, UserID: ev.Sender} + b.Remote <- rmsg } flog.Debugf("Received: %#v", ev) }) |