all repos — telegram-bot-api @ f605a516c08839642762afae21c793be36659996

Golang bindings for the Telegram Bot API

string function for user
Syfaro syfaro@foxpaw.in
Fri, 31 Jul 2015 03:22:01 -0400
commit

f605a516c08839642762afae21c793be36659996

parent

8907d30fe069524828c7d37917e0bd287911b065

1 files changed, 16 insertions(+), 0 deletions(-)

jump to
M types.gotypes.go

@@ -26,6 +26,22 @@ LastName string `json:"last_name"`

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"`