Merge pull request #94 from mamal72/add-language-code-to-user

Add language code to user struct
bot-api-6.1
Syfaro 2017-05-23 02:53:20 -05:00 committed by GitHub
commit 5869b2f7f9
2 changed files with 9 additions and 7 deletions

View File

@ -49,10 +49,11 @@ func (ch UpdatesChannel) Clear() {
// User is a user on Telegram.
type User struct {
ID int `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"` // optional
UserName string `json:"username"` // optional
ID int `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"` // optional
UserName string `json:"username"` // optional
LanguageCode string `json:"language_code"` // optional
}
// String displays a simple text version of a user.

View File

@ -1,13 +1,14 @@
package tgbotapi_test
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"testing"
"time"
"github.com/go-telegram-bot-api/telegram-bot-api"
)
func TestUserStringWith(t *testing.T) {
user := tgbotapi.User{0, "Test", "Test", ""}
user := tgbotapi.User{0, "Test", "Test", "", "en"}
if user.String() != "Test Test" {
t.Fail()
@ -15,7 +16,7 @@ func TestUserStringWith(t *testing.T) {
}
func TestUserStringWithUserName(t *testing.T) {
user := tgbotapi.User{0, "Test", "Test", "@test"}
user := tgbotapi.User{0, "Test", "Test", "@test", "en"}
if user.String() != "@test" {
t.Fail()