5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-26 00:51:36 +00:00

Add NoHomeServerSuffix. Option to disable homeserver on username (matrix). Closes #160.

This commit is contained in:
Wim 2017-05-12 23:04:58 +02:00
parent ee643de5b6
commit 4036d4459b
2 changed files with 10 additions and 2 deletions

View File

@ -52,6 +52,7 @@ type Protocol struct {
NickServNick string // IRC
NickServPassword string // IRC
NicksPerRow int // mattermost, slack
NoHomeServerSuffix bool // matrix
NoTLS bool // mattermost
Password string // IRC,mattermost,XMPP,matrix
PrefixMessagesWithNick bool // mattemost, slack

View File

@ -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)
})