Merge remote-tracking branch 'pr0head/master' into develop
Syfaro syfaro@huefox.com
Fri, 29 Dec 2017 12:56:31 -0600
5 files changed,
67 insertions(+),
14 deletions(-)
M
bot_test.go
→
bot_test.go
@@ -266,7 +266,7 @@
func TestSendWithLocation(t *testing.T) { bot, _ := getBot(t) - _, err := bot.Send(tgbotapi.NewLocation(ChatID, 40, 40)) + _, err := bot.Send(tgbotapi.NewLocation(ChatID, 40, 40, 86400)) if err != nil { t.Error(err)
M
configs.go
→
configs.go
@@ -571,8 +571,9 @@
// LocationConfig contains information about a SendLocation request. type LocationConfig struct { BaseChat - Latitude float64 // required - Longitude float64 // required + Latitude float64 // required + Longitude float64 // required + LivePeriod int // optional } // values returns a url.Values representation of LocationConfig.@@ -584,6 +585,9 @@ }
v.Add("latitude", strconv.FormatFloat(config.Latitude, 'f', 6, 64)) v.Add("longitude", strconv.FormatFloat(config.Longitude, 'f', 6, 64)) + if config.LivePeriod != 0 { + v.Add("live_period", strconv.Itoa(config.LivePeriod)) + } return v, nil }@@ -591,6 +595,51 @@
// method returns Telegram API method name for sending Location. func (config LocationConfig) method() string { return "sendLocation" +} + +// LocationConfig contains information about a SendLocation request. +type EditMessageLiveLocationConfig struct { + BaseEdit + Latitude float64 // required + Longitude float64 // required +} + +// values returns a url.Values representation of EditMessageLiveLocationConfig. +func (config EditMessageLiveLocationConfig) values() (url.Values, error) { + v, err := config.BaseEdit.values() + if err != nil { + return v, err + } + + v.Add("latitude", strconv.FormatFloat(config.Latitude, 'f', 6, 64)) + v.Add("longitude", strconv.FormatFloat(config.Longitude, 'f', 6, 64)) + + return v, nil +} + +// method returns Telegram API method name for edit message Live Location. +func (config EditMessageLiveLocationConfig) method() string { + return "editMessageLiveLocation" +} + +// LocationConfig contains information about a StopMessageLiveLocation request. +type StopMessageLiveLocationConfig struct { + BaseEdit +} + +// values returns a url.Values representation of StopMessageLiveLocationConfig. +func (config StopMessageLiveLocationConfig) values() (url.Values, error) { + v, err := config.BaseEdit.values() + if err != nil { + return v, err + } + + return v, nil +} + +// method returns Telegram API method name for stop message Live Location. +func (config StopMessageLiveLocationConfig) method() string { + return "stopMessageLiveLocation" } // VenueConfig contains information about a SendVenue request.
M
helpers.go
→
helpers.go
@@ -268,13 +268,14 @@
// NewLocation shares your location. // // chatID is where to send it, latitude and longitude are coordinates. -func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig { +func NewLocation(chatID int64, latitude float64, longitude float64, live_period int) LocationConfig { return LocationConfig{ BaseChat: BaseChat{ ChatID: chatID, }, - Latitude: latitude, - Longitude: longitude, + Latitude: latitude, + Longitude: longitude, + LivePeriod: live_period, } }@@ -465,13 +466,14 @@ }
} // NewInlineQueryResultLocation creates a new inline query location. -func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation { +func NewInlineQueryResultLocation(id, title string, latitude, longitude float64, live_period int) InlineQueryResultLocation { return InlineQueryResultLocation{ - Type: "location", - ID: id, - Title: title, - Latitude: latitude, - Longitude: longitude, + Type: "location", + ID: id, + Title: title, + Latitude: latitude, + Longitude: longitude, + LivePeriod: live_period, } }
M
helpers_test.go
→
helpers_test.go
@@ -127,13 +127,14 @@ }
} func TestNewInlineQueryResultLocation(t *testing.T) { - result := tgbotapi.NewInlineQueryResultLocation("id", "name", 40, 50) + result := tgbotapi.NewInlineQueryResultLocation("id", "name", 40, 50, 86400) if result.Type != "location" || result.ID != "id" || result.Title != "name" || result.Latitude != 40 || - result.Longitude != 50 { + result.Longitude != 50 || + result.LivePeriod != 86400 { t.Fail() } }
M
types.go
→
types.go
@@ -662,6 +662,7 @@ Type string `json:"type"` // required
ID string `json:"id"` // required Latitude float64 `json:"latitude"` // required Longitude float64 `json:"longitude"` // required + LivePeriod int `json:"live_period"` // optional Title string `json:"title"` // required ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`