From 72f87b43e3794101f980c610fcadd3fcdcf73bc9 Mon Sep 17 00:00:00 2001 From: Syfaro Date: Fri, 29 Dec 2017 13:00:02 -0600 Subject: [PATCH] Fix backwards compatibility for Live Location. --- bot_test.go | 2 +- configs.go | 4 ++-- helpers.go | 20 +++++++++----------- helpers_test.go | 5 ++--- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/bot_test.go b/bot_test.go index 5aa6802..cb584dc 100644 --- a/bot_test.go +++ b/bot_test.go @@ -266,7 +266,7 @@ func TestSendWithContact(t *testing.T) { func TestSendWithLocation(t *testing.T) { bot, _ := getBot(t) - _, err := bot.Send(tgbotapi.NewLocation(ChatID, 40, 40, 86400)) + _, err := bot.Send(tgbotapi.NewLocation(ChatID, 40, 40)) if err != nil { t.Error(err) diff --git a/configs.go b/configs.go index 0670a9b..651dabc 100644 --- a/configs.go +++ b/configs.go @@ -600,8 +600,8 @@ func (config LocationConfig) method() string { // LocationConfig contains information about a SendLocation request. type EditMessageLiveLocationConfig struct { BaseEdit - Latitude float64 // required - Longitude float64 // required + Latitude float64 // required + Longitude float64 // required } // values returns a url.Values representation of EditMessageLiveLocationConfig. diff --git a/helpers.go b/helpers.go index 2c5d046..132d957 100644 --- a/helpers.go +++ b/helpers.go @@ -268,14 +268,13 @@ func NewContact(chatID int64, phoneNumber, firstName string) ContactConfig { // NewLocation shares your location. // // chatID is where to send it, latitude and longitude are coordinates. -func NewLocation(chatID int64, latitude float64, longitude float64, live_period int) LocationConfig { +func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig { return LocationConfig{ BaseChat: BaseChat{ ChatID: chatID, }, - Latitude: latitude, - Longitude: longitude, - LivePeriod: live_period, + Latitude: latitude, + Longitude: longitude, } } @@ -466,14 +465,13 @@ func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryRe } // NewInlineQueryResultLocation creates a new inline query location. -func NewInlineQueryResultLocation(id, title string, latitude, longitude float64, live_period int) InlineQueryResultLocation { +func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation { return InlineQueryResultLocation{ - Type: "location", - ID: id, - Title: title, - Latitude: latitude, - Longitude: longitude, - LivePeriod: live_period, + Type: "location", + ID: id, + Title: title, + Latitude: latitude, + Longitude: longitude, } } diff --git a/helpers_test.go b/helpers_test.go index d2a9027..7cb5c0b 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -127,14 +127,13 @@ func TestNewInlineQueryResultDocument(t *testing.T) { } func TestNewInlineQueryResultLocation(t *testing.T) { - result := tgbotapi.NewInlineQueryResultLocation("id", "name", 40, 50, 86400) + result := tgbotapi.NewInlineQueryResultLocation("id", "name", 40, 50) if result.Type != "location" || result.ID != "id" || result.Title != "name" || result.Latitude != 40 || - result.Longitude != 50 || - result.LivePeriod != 86400 { + result.Longitude != 50 { t.Fail() } }