Update handlers.go
Add ability to use FullName, FirstName, LastName, NickName or UserName(if neither is set) as nick for Mattermost
This commit is contained in:
		@@ -142,10 +142,28 @@ func (b *Bmattermost) handleMatterClient(messages chan *config.Message) {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Use nickname instead of username if defined
 | 
					                // Choose what to use as user nick Nickname/FullName/FirstName/LastName (or Username if neither is set)
 | 
				
			||||||
		if !b.GetBool("useusername") {
 | 
					                if b.GetBool("UseNickName") {
 | 
				
			||||||
			if nick := b.mc.GetNickName(rmsg.UserID); nick != "" {
 | 
					                        if b.mc.GetNickName(rmsg.UserID) != "" {
 | 
				
			||||||
				rmsg.Username = nick
 | 
					                                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 = ""
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user