diff --git a/configs.go b/configs.go index 181d4e4..2e0f7dc 100644 --- a/configs.go +++ b/configs.go @@ -688,6 +688,7 @@ type LocationConfig struct { BaseChat Latitude float64 // required Longitude float64 // required + LivePeriod int64 //between 60 and 86400 } // values returns a url.Values representation of LocationConfig. @@ -699,7 +700,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.FormatInt(config.LivePeriod, 10)) + } return v, nil } @@ -708,6 +711,49 @@ func (config LocationConfig) method() string { return "sendLocation" } +type EditLiveLocationConfig struct { + BaseEdit + Latitude float64 // required + Longitude float64 // required +} + +// values returns a url.Values representation of EditLiveLocationConfig. +func (config EditLiveLocationConfig) 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 updating live Location. +func (config EditLiveLocationConfig) method() string { + return "editMessageLiveLocation" +} + +type StopLiveLocationConfig struct { + BaseEdit +} + +// values returns a url.Values representation of StopLiveLocationConfig. +func (config StopLiveLocationConfig) 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 stopping live location. +func (config StopLiveLocationConfig) method() string { + return "stopMessageLiveLocation" +} + // VenueConfig contains information about a SendVenue request. type VenueConfig struct { BaseChat diff --git a/helpers.go b/helpers.go index 3dabe11..25b4270 100644 --- a/helpers.go +++ b/helpers.go @@ -338,6 +338,27 @@ func NewLocation(chatID int64, latitude float64, longitude float64) LocationConf }, Latitude: latitude, Longitude: longitude, + LivePeriod: 0, + } +} + +func NewEditLiveLocation(chatId int64, messageId int, latitude float64, longitude float64) EditLiveLocationConfig{ + return EditLiveLocationConfig{ + BaseEdit: BaseEdit{ + ChatID: chatId, + MessageID:messageId, + }, + Latitude: latitude, + Longitude: longitude, + } +} + +func NewStopLiveLocation(chatId int64, messageId int) StopLiveLocationConfig{ + return StopLiveLocationConfig{ + BaseEdit: BaseEdit{ + ChatID: chatId, + MessageID:messageId, + }, } }