diff options
author | Wim <wim@42.be> | 2017-05-12 23:04:58 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-05-12 23:04:58 +0200 |
commit | 4036d4459b69adda1f60695ec6196630b229a633 (patch) | |
tree | 33a25b54bad66cbc48026f56c52bbb402e13a396 /bridge/matrix | |
parent | ee643de5b6031b6bdbf2e957f2fea8f1222ace64 (diff) | |
download | matterbridge-msglm-4036d4459b69adda1f60695ec6196630b229a633.tar.gz matterbridge-msglm-4036d4459b69adda1f60695ec6196630b229a633.tar.bz2 matterbridge-msglm-4036d4459b69adda1f60695ec6196630b229a633.zip |
Add NoHomeServerSuffix. Option to disable homeserver on username (matrix). Closes #160.
Diffstat (limited to 'bridge/matrix')
-rw-r--r-- | bridge/matrix/matrix.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index add7e408..628e8d91 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -1,10 +1,12 @@ package bmatrix import ( + "regexp" + "sync" + "github.com/42wim/matterbridge/bridge/config" log "github.com/Sirupsen/logrus" matrix "github.com/matrix-org/gomatrix" - "sync" ) type Bmatrix struct { @@ -101,8 +103,13 @@ func (b *Bmatrix) handlematrix() error { flog.Debugf("Unknown room %s", ev.RoomID) return } + username := ev.Sender[1:] + if b.Config.NoHomeServerSuffix { + re := regexp.MustCompile("(.*?):.*") + username = re.ReplaceAllString(username, `$1`) + } flog.Debugf("Sending message from %s on %s to gateway", ev.Sender, b.Account) - b.Remote <- config.Message{Username: ev.Sender, Text: ev.Content["body"].(string), Channel: channel, Account: b.Account} + b.Remote <- config.Message{Username: username, Text: ev.Content["body"].(string), Channel: channel, Account: b.Account} } flog.Debugf("Received: %#v", ev) }) |