Added `live_period` for Location

bot-api-6.1
pr0head 2017-10-13 17:00:04 +03:00
parent 846d467e14
commit 65947daaab
3 changed files with 29 additions and 20 deletions

View File

@ -573,6 +573,7 @@ type LocationConfig struct {
BaseChat
Latitude float64 // required
Longitude float64 // required
LivePeriod int // optional
}
// values returns a url.Values representation of LocationConfig.
@ -584,6 +585,9 @@ func (config LocationConfig) values() (url.Values, error) {
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
}

View File

@ -268,13 +268,14 @@ 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) LocationConfig {
func NewLocation(chatID int64, latitude float64, longitude float64, live_period int) LocationConfig {
return LocationConfig{
BaseChat: BaseChat{
ChatID: chatID,
},
Latitude: latitude,
Longitude: longitude,
LivePeriod: live_period,
}
}
@ -465,13 +466,14 @@ func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryRe
}
// 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,
LivePeriod: live_period,
}
}

View File

@ -333,6 +333,7 @@ type Contact struct {
type Location struct {
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
LivePeriod int `json:"live_period"`
}
// Venue contains information about a venue, including its Location.
@ -643,6 +644,7 @@ type InlineQueryResultLocation struct {
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"`
@ -681,6 +683,7 @@ type InputTextMessageContent struct {
type InputLocationMessageContent struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
LivePeriod int `json:"live_period"`
}
// InputVenueMessageContent contains a venue for displaying