mirror of
https://github.com/42wim/matterbridge.git
synced 2025-04-18 01:42:20 +03:00
Merge b502420de89c9f1c5825f2a6e01a0a323ae5366c into c4157a4d5b49fce79c80a30730dc7c404bacd663
This commit is contained in:
commit
4ede82486c
@ -170,7 +170,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
|
||||
|
@ -144,12 +144,30 @@ 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
|
||||
}
|
||||
}
|
||||
// Choose what to use as user nick Nickname/FullName/FirstName/LastName (or Username if neither is set)
|
||||
if b.GetBool("UseNickName") {
|
||||
if b.mc.GetNickName(rmsg.UserID) != "" {
|
||||
rmsg.Username = b.mc.GetNickName(rmsg.UserID)
|
||||
}
|
||||
} else if b.GetBool("UseFirstName") {
|
||||
if b.mc.GetFirstName(rmsg.UserID) != "" {
|
||||
rmsg.Username = b.mc.GetFirstName(rmsg.UserID)
|
||||
}
|
||||
} else if b.GetBool("UseLastName") {
|
||||
if b.mc.GetLastName(rmsg.UserID) != "" {
|
||||
rmsg.Username = b.mc.GetLastName(rmsg.UserID)
|
||||
}
|
||||
} else if b.GetBool("UseFullName") {
|
||||
if b.mc.GetFirstName(rmsg.UserID) != "" && b.mc.GetLastName(rmsg.UserID) != "" {
|
||||
rmsg.Username = b.mc.GetFirstName(rmsg.UserID) + " " + b.mc.GetLastName(rmsg.UserID)
|
||||
} else if b.mc.GetFirstName(rmsg.UserID) != "" {
|
||||
rmsg.Username = b.mc.GetFirstName(rmsg.UserID)
|
||||
} else if b.mc.GetLastName(rmsg.UserID) != "" {
|
||||
rmsg.Username = b.mc.GetLastName(rmsg.UserID)
|
||||
} else {
|
||||
rmsg.Username = ""
|
||||
}
|
||||
}
|
||||
|
||||
messages <- rmsg
|
||||
}
|
||||
|
@ -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"
|
||||
|
16
vendor/github.com/matterbridge/matterclient/users.go
generated
vendored
16
vendor/github.com/matterbridge/matterclient/users.go
generated
vendored
@ -14,6 +14,22 @@ func (m *Client) GetNickName(userID string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Client) GetFirstName(userID string) string {
|
||||
if user := m.GetUser(userID); user != nil {
|
||||
return user.FirstName
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Client) GetLastName(userID string) string {
|
||||
if user := m.GetUser(userID); user != nil {
|
||||
return user.LastName
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Client) GetStatus(userID string) string {
|
||||
res, _, err := m.Client.GetUserStatus(context.TODO(), userID, "")
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user