Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nctalk: Add option to use User ID instead of Display Name as nick #1252

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
10 changes: 7 additions & 3 deletions bridge/nctalk/nctalk.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error {
if b.IsKeySet("GuestSuffix") {
guestSuffix = b.GetString("GuestSuffix")
}
userIDAsNick := b.GetBool("UserIdAsNick")

go func() {
for msg := range c {
Expand All @@ -88,7 +89,7 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error {
remoteMessage := config.Message{
Text: formatRichObjectString(msg.Message, msg.MessageParameters),
Channel: newRoom.room.Token,
Username: DisplayName(msg, guestSuffix),
Username: DisplayName(msg, guestSuffix, userIDAsNick),
UserID: msg.ActorID,
Account: b.Account,
}
Expand Down Expand Up @@ -152,14 +153,17 @@ func formatRichObjectString(message string, parameters map[string]ocs.RichObject
return message
}

func DisplayName(msg ocs.TalkRoomMessageData, suffix string) string {
func DisplayName(msg ocs.TalkRoomMessageData, suffix string, userIDAsName bool) string {
if msg.ActorType == ocs.ActorGuest {
if msg.ActorDisplayName == "" {
return "Guest"
}

return msg.ActorDisplayName + suffix
}

// Use the user ID instead of the display name for non-guest users
if userIDAsName {
return msg.ActorID
}
return msg.ActorDisplayName
}
3 changes: 3 additions & 0 deletions matterbridge.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,9 @@ Password = "talkuserpass"

# Suffix for Guest Users
GuestSuffix = " (Guest)"
# If true, use the User ID instead of Display Name for non-guest users (default false)
# WARNING: Before using this, verify that your user IDs are indeed human-readable and intended for display.
UserIdAsNick = false

###################################################################
#
Expand Down