Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
fwzookeeper/vendor/gitlab.com/toby3d/telegram/send_location.go

58 lines
1.7 KiB
Go
Raw Normal View History

2018-12-22 17:38:56 +04:00
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// SendLocationParameters represents data for SendLocation method.
type SendLocationParameters struct {
// Unique identifier for the target private chat
ChatID int64 `json:"chat_id"`
// Latitude of the location
Latitude float32 `json:"latitude"`
// Longitude of the location
Longitude float32 `json:"longitude"`
// Period in seconds for which the location will be updated (see Live
// Locations), should be between 60 and 86400.
LivePeriod int `json:"live_period,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// A JSON-serialized object for an inline keyboard. If empty, one 'Pay total
// price' button will be shown. If not empty, the first button must be a Pay
// button.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// NewLocation creates SendLocationParameters only with required parameters.
func NewLocation(chatID int64, latitude, longitude float32) *SendLocationParameters {
return &SendLocationParameters{
ChatID: chatID,
Latitude: latitude,
Longitude: longitude,
}
}
// SendLocation send point on the map. On success, the sent Message is returned.
func (bot *Bot) SendLocation(params *SendLocationParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodSendLocation)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}