string function for user

bot-api-6.1
Syfaro 2015-07-31 03:22:01 -04:00
parent 8907d30fe0
commit f605a516c0
1 changed files with 16 additions and 0 deletions

View File

@ -26,6 +26,22 @@ type User struct {
UserName string `json:"username"`
}
// String displays a simple text version of a user.
// It is normally a user's username,
// but falls back to a first/last name as available.
func (u *User) String() string {
if u.UserName != "" {
return u.UserName
}
name := u.FirstName
if u.LastName != "" {
name += " " + u.LastName
}
return name
}
// GroupChat is a group chat, and not currently in use.
type GroupChat struct {
ID int `json:"id"`