Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bridge/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ type Protocol struct {
UseSASL bool // IRC
UseTLS bool // IRC
UseDiscriminator bool // discord
UseFirstName bool // telegram
UseFullName bool // mattermost
UseFirstName bool // telegram, mattermost
UseLastName bool // mattermost
UseUserName bool // discord, matrix, mattermost
UseInsecureURL bool // telegram
UserName string // IRC
Expand Down
46 changes: 36 additions & 10 deletions bridge/mattermost/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/matterbridge-org/matterbridge/bridge/config"
"github.com/matterbridge-org/matterbridge/bridge/helper"
"github.com/matterbridge/matterclient"
"github.com/matterbridge-org/matterclient"
"github.com/mattermost/mattermost/server/public/model"
)

Expand Down Expand Up @@ -144,15 +144,41 @@ func (b *Bmattermost) handleMatterClient(messages chan *config.Message) {
}
}

// Use nickname instead of username if defined
if !b.GetBool("useusername") {
if nick := b.mc.GetNickName(rmsg.UserID); nick != "" {
rmsg.Username = nick
}
}

messages <- rmsg
}
// Choose what to use as user nick Nickname/FullName/FirstName/LastName (or Username if neither is set)
switch {
case b.GetBool("UseNickName"):
if nickname := b.mc.GetNickName(rmsg.UserID); nickname != "" {
rmsg.Username = nickname
}

case b.GetBool("UseFirstName"):
if firstname := b.mc.GetFirstName(rmsg.UserID); firstname != "" {
rmsg.Username = firstname
}

case b.GetBool("UseLastName"):
if lastname := b.mc.GetLastName(rmsg.UserID); lastname != "" {
rmsg.Username = lastname
}

case b.GetBool("UseFullName"):
first := b.mc.GetFirstName(rmsg.UserID)
last := b.mc.GetLastName(rmsg.UserID)

switch {
case first != "" && last != "":
rmsg.Username = first + " " + last
case first != "":
rmsg.Username = first
case last != "":
rmsg.Username = last
default:
rmsg.Username = "NoName"
}
}

messages <- rmsg
}
}

func (b *Bmattermost) handleMatterHook(messages chan *config.Message) {
Expand Down
2 changes: 1 addition & 1 deletion bridge/mattermost/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/matterbridge-org/matterbridge/bridge/config"
"github.com/matterbridge-org/matterbridge/bridge/helper"
"github.com/matterbridge-org/matterbridge/matterhook"
"github.com/matterbridge/matterclient"
"github.com/matterbridge-org/matterclient"
"github.com/mattermost/mattermost/server/public/model"
)

Expand Down
2 changes: 1 addition & 1 deletion bridge/mattermost/mattermost.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/matterbridge-org/matterbridge/bridge/config"
"github.com/matterbridge-org/matterbridge/bridge/helper"
"github.com/matterbridge-org/matterbridge/matterhook"
"github.com/matterbridge/matterclient"
"github.com/matterbridge-org/matterclient"
"github.com/rs/xid"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20211016222428-79310a412696
github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75
github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba
github.com/matterbridge/matterclient v0.0.0-20240817214420-3d4c3aef3dc1
github.com/matterbridge-org/matterclient v0.0.1
github.com/matterbridge/telegram-bot-api/v6 v6.5.0
github.com/mattermost/mattermost/server/public v0.1.6
github.com/mattn/go-mastodon v0.0.10
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75 h1:GslZKF7
github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75/go.mod h1:yAjnZ34DuDyPHMPHHjOsTk/FefW4JJjoMMCGt/8uuQA=
github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba h1:XleOY4IjAEIcxAh+IFwT5JT5Ze3RHiYz6m+4ZfZ0rc0=
github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba/go.mod h1:iXGEotOvwI1R1SjLxRc+BF5rUORTMtE0iMZBT2lxqAU=
github.com/matterbridge/matterclient v0.0.0-20240817214420-3d4c3aef3dc1 h1:LHzlbT3VIcRFhSPwKpZfT2TU2rUzuA8liF57gSEBuaI=
github.com/matterbridge/matterclient v0.0.0-20240817214420-3d4c3aef3dc1/go.mod h1:quMZkUhnTp/YfbJU6sCgD6qVSPgH1Uxig9/AjgJQHF8=
github.com/matterbridge-org/matterclient v0.0.1 h1:0Wtcf3BrOfnmWV/05mta3lagEIZy03nZAMuXbBq6r0I=
github.com/matterbridge-org/matterclient v0.0.1/go.mod h1:qT2nKnISsB0W9feG5a1C9o0Bnye8H7lwfDEnwCA0yCs=
github.com/matterbridge/telegram-bot-api/v6 v6.5.0 h1:wCnHWvt4WGhfognQsuu2OnHyqENBdJRf2mReYTCXggQ=
github.com/matterbridge/telegram-bot-api/v6 v6.5.0/go.mod h1:/hSLrs8h/xNsQglQXjwXJ92iZU8XfTGkYUQ7KVDWEVo=
github.com/mattermost/go-i18n v1.11.1-0.20211013152124-5c415071e404 h1:Khvh6waxG1cHc4Cz5ef9n3XVCxRWpAKUtqg9PJl5+y8=
Expand Down
8 changes: 6 additions & 2 deletions matterbridge.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,13 @@ SkipTLSVerify=true
## RELOADABLE SETTINGS
## Settings below can be reloaded by editing the file

# UseUserName shows the username instead of the server nickname
# Choose what use as user nick NickName/FullName/FirstName/LastName/UserName
# OPTIONAL (default false)
UseUserName=false
UseNickName=false
UseFullName=false
UseFirstName=false
UseLastName=false
#if neither is set as true will use username

#how to format the list of IRC nicks when displayed in mattermost.
#Possible options are "table" and "plain"
Expand Down
Loading