1
0

Added SendVenue method

This commit is contained in:
Maxim Lebedev 2018-02-15 17:42:52 +05:00
parent 978d73f05f
commit 8bf32554f0
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F

62
send_venue.go Normal file
View File

@ -0,0 +1,62 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
type SendVenueParameters struct {
// Unique identifier for the target private chat
ChatID int64 `json:"chat_id"`
// Latitude of the venue
Latitude float32 `json:"latitude"`
// Longitude of the venue
Longitude float32 `json:"longitude"`
// Name of the venue
Title string `json:"title"`
// Address of the venue
Address string `json:"address"`
// Foursquare identifier of the venue
FoursquareID string `json:"foursquare_id,omitempty"`
// Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,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"`
}
func NewVenue(chatID int64, latitude, longitude float32, title, address string) *SendVenueParameters {
return &SendVenueParameters{
ChatID: chatID,
Latitude: latitude,
Longitude: longitude,
Title: title,
Address: address,
}
}
// SendVenue send information about a venue. On success, the sent Message is returned.
func (bot *Bot) SendVenue(params *SendVenueParameters) (*Message, error) {
dst, err := json.Marshal(params)
if err != nil {
return nil, err
}
resp, err := bot.request(dst, "sendVenue")
if err != nil {
return nil, err
}
var data Message
err = json.Unmarshal(*resp.Result, &data)
return &data, err
}