From f1c5a5b19796bfdbcdb5b0ca52d1661994412328 Mon Sep 17 00:00:00 2001 From: Demian Date: Wed, 8 Dec 2021 20:14:24 +0200 Subject: [PATCH] change user id type to int64 --- bot_test.go | 6 +++--- chat.go | 4 ++-- media.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bot_test.go b/bot_test.go index 958bfecd..4f989b49 100644 --- a/bot_test.go +++ b/bot_test.go @@ -13,14 +13,14 @@ import ( ) const ( - photoID = "AgACAgIAAxkDAAIBV16Ybpg7l2jPgMUiiLJ3WaQOUqTrAAJorjEbh2TBSPSOinaCHfydQO_pki4AAwEAAwIAA3kAA_NQAAIYBA" + photoURL = "https://telegra.ph/file/4e477a2abc5f53c0bb4aa.jpg" ) var ( // required to test send and edit methods token = os.Getenv("TELEBOT_SECRET") chatID, _ = strconv.ParseInt(os.Getenv("CHAT_ID"), 10, 64) - userID, _ = strconv.Atoi(os.Getenv("USER_ID")) + userID, _ = strconv.ParseInt(os.Getenv("USER_ID"), 10, 64) b, _ = newTestBot() // cached bot instance to avoid getMe method flooding to = &Chat{ID: chatID} // to chat recipient for send and edit methods @@ -313,7 +313,7 @@ func TestBot(t *testing.T) { assert.Equal(t, ErrBadRecipient, err) photo := &Photo{ - File: File{FileID: photoID}, + File: File{FileURL: photoURL}, Caption: t.Name(), } var msg *Message diff --git a/chat.go b/chat.go index b2c3bfba..2f8e9615 100644 --- a/chat.go +++ b/chat.go @@ -4,7 +4,7 @@ import "strconv" // User object represents a Telegram user, bot. type User struct { - ID int `json:"id"` + ID int64 `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` @@ -20,7 +20,7 @@ type User struct { // Recipient returns user ID (see Recipient interface). func (u *User) Recipient() string { - return strconv.Itoa(u.ID) + return strconv.FormatInt(u.ID, 10) } // Chat object represents a Telegram user, bot, group or a channel. diff --git a/media.go b/media.go index 48dd3a87..4d67c706 100644 --- a/media.go +++ b/media.go @@ -184,7 +184,7 @@ type Contact struct { // (Optional) LastName string `json:"last_name"` - UserID int `json:"user_id,omitempty"` + UserID int64 `json:"user_id,omitempty"` } // Location object represents geographic position.