mirror of
https://github.com/tucnak/telebot
synced 2024-11-15 06:13:01 +00:00
46992b037b
These changes make it possible to set custom options when responding to inline queries, as described on https://core.telegram.org/bots/api#answerinlinequery. It also includes all the (non-cached) inline result types as described at https://core.telegram.org/bots/api#inlinequeryresult. Some remarks: * The internals of sendCommand have changed. It now expects a JSON-serializable object. Instead of doing GET requests with URL-encoded query parameters it now POSTS JSON directly. * Because of the above, sendFile() has changed as well. It now expects a * `map[string]string` which it will internally convert to URL encoded form values. * Respond has been deprecated in favor of the new AnswerInlineQuery function. It is only kept for backward compatibility. * A dependency on https://github.com/mitchellh/hashstructure has been introduced in order to generate automatic IDs for inline results.
691 lines
20 KiB
Go
691 lines
20 KiB
Go
package telebot
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
// InlineQueryResultArticle represents a link to an article or web page.
|
|
// See also: https://core.telegram.org/bots/api#inlinequeryresultarticle
|
|
type InlineQueryResultArticle struct {
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
|
// from the other fields and used automatically.
|
|
ID string `json:"id",hash:"ignore"`
|
|
|
|
// Title of the result.
|
|
Title string `json:"title"`
|
|
|
|
// Message text. Shortcut (and mutually exclusive to) specifying
|
|
// InputMessageContent.
|
|
Text string `json:"message_text,omitempty"`
|
|
|
|
// Content of the message to be sent.
|
|
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
|
|
// Optional. URL of the result.
|
|
URL string `json:"url,omitempty"`
|
|
|
|
// Optional. Pass True, if you don't want the URL to be shown in the message.
|
|
HideURL bool `json:"hide_url,omitempty"`
|
|
|
|
// Optional. Short description of the result.
|
|
Description string `json:"description,omitempty"`
|
|
|
|
// Optional. Url of the thumbnail for the result.
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
|
|
|
// Optional. Thumbnail width.
|
|
ThumbWidth int `json:"thumb_width,omitempty"`
|
|
|
|
// Optional. Thumbnail height.
|
|
ThumbHeight int `json:"thumb_height,omitempty"`
|
|
}
|
|
|
|
// Used to avoid endless recursion in MarshalJSON.
|
|
type wrappedInlineQueryResultArticle InlineQueryResultArticle
|
|
|
|
func (r *InlineQueryResultArticle) MarshalJSON() ([]byte, error) {
|
|
id, err := r.id()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return json.Marshal(struct {
|
|
wrappedInlineQueryResultArticle
|
|
Type string `json:"type"`
|
|
ID string `json:"id",hash:"ignore"`
|
|
}{
|
|
wrappedInlineQueryResultArticle: wrappedInlineQueryResultArticle(*r),
|
|
ID: id,
|
|
Type: "article",
|
|
})
|
|
}
|
|
|
|
func (r *InlineQueryResultArticle) id() (string, error) {
|
|
if r.ID == "" {
|
|
return hashInlineQueryResult(r)
|
|
} else {
|
|
return r.ID, nil
|
|
}
|
|
}
|
|
|
|
// InlineQueryResultAudio represents a link to an mp3 audio file.
|
|
type InlineQueryResultAudio struct {
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
|
// from the other fields and used automatically.
|
|
ID string `json:"id",hash:"ignore"`
|
|
|
|
// A valid URL for the audio file.
|
|
AudioURL string `json:"audio_url"`
|
|
|
|
// Title.
|
|
Title string `json:"title"`
|
|
|
|
// Optional. Performer.
|
|
Performer string `json:"performer,omitempty"`
|
|
|
|
// Optional. Audio duration in seconds.
|
|
Duration int `json:"audio_duration,omitempty"`
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
|
|
// Optional. Content of the message to be sent instead of the audio.
|
|
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
|
|
}
|
|
|
|
// Used to avoid endless recursion in MarshalJSON.
|
|
type wrappedInlineQueryResultAudio InlineQueryResultAudio
|
|
|
|
func (r *InlineQueryResultAudio) MarshalJSON() ([]byte, error) {
|
|
id, err := r.id()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return json.Marshal(struct {
|
|
wrappedInlineQueryResultAudio
|
|
Type string `json:"type"`
|
|
ID string `json:"id",hash:"ignore"`
|
|
}{
|
|
wrappedInlineQueryResultAudio: wrappedInlineQueryResultAudio(*r),
|
|
ID: id,
|
|
Type: "audio",
|
|
})
|
|
}
|
|
|
|
func (r *InlineQueryResultAudio) id() (string, error) {
|
|
if r.ID == "" {
|
|
return hashInlineQueryResult(r)
|
|
} else {
|
|
return r.ID, nil
|
|
}
|
|
}
|
|
|
|
// InlineQueryResultContact represents a contact with a phone number.
|
|
// See also: https://core.telegram.org/bots/api#inlinequeryresultcontact
|
|
type InlineQueryResultContact struct {
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
|
// from the other fields and used automatically.
|
|
ID string `json:"id",hash:"ignore"`
|
|
|
|
// Contact's phone number.
|
|
PhoneNumber string `json:"phone_number"`
|
|
|
|
// Contact's first name.
|
|
FirstName string `json:"first_name"`
|
|
|
|
// Optional. Contact's last name.
|
|
LastName string `json:"last_name,omitempty"`
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
|
|
// Optional. Content of the message to be sent instead of the audio.
|
|
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
|
|
|
|
// Optional. Url of the thumbnail for the result.
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
|
|
|
// Optional. Thumbnail width.
|
|
ThumbWidth int `json:"thumb_width,omitempty"`
|
|
|
|
// Optional. Thumbnail height.
|
|
ThumbHeight int `json:"thumb_height,omitempty"`
|
|
}
|
|
|
|
// Used to avoid endless recursion in MarshalJSON.
|
|
type wrappedInlineQueryResultContact InlineQueryResultContact
|
|
|
|
func (r *InlineQueryResultContact) MarshalJSON() ([]byte, error) {
|
|
id, err := r.id()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return json.Marshal(struct {
|
|
wrappedInlineQueryResultContact
|
|
Type string `json:"type"`
|
|
ID string `json:"id",hash:"ignore"`
|
|
}{
|
|
wrappedInlineQueryResultContact: wrappedInlineQueryResultContact(*r),
|
|
ID: id,
|
|
Type: "contact",
|
|
})
|
|
}
|
|
|
|
func (r *InlineQueryResultContact) id() (string, error) {
|
|
if r.ID == "" {
|
|
return hashInlineQueryResult(r)
|
|
} else {
|
|
return r.ID, nil
|
|
}
|
|
}
|
|
|
|
// InlineQueryResultDocument represents a link to a file.
|
|
// See also: https://core.telegram.org/bots/api#inlinequeryresultdocument
|
|
type InlineQueryResultDocument struct {
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
|
// from the other fields and used automatically.
|
|
ID string `json:"id",hash:"ignore"`
|
|
|
|
// Title for the result.
|
|
Title string `json:"title"`
|
|
|
|
// A valid URL for the file
|
|
DocumentURL string `json:"document_url"`
|
|
|
|
// Mime type of the content of the file, either “application/pdf” or
|
|
// “application/zip”.
|
|
MimeType string `json:"mime_type"`
|
|
|
|
// Optional. Caption of the document to be sent, 0-200 characters.
|
|
Caption string `json:"caption,omitempty"`
|
|
|
|
// Optional. Short description of the result.
|
|
Description string `json:"description,omitempty"`
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
|
|
// Optional. Content of the message to be sent instead of the audio.
|
|
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
|
|
|
|
// Optional. URL of the thumbnail (jpeg only) for the file.
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
|
|
|
// Optional. Thumbnail width.
|
|
ThumbWidth int `json:"thumb_width,omitempty"`
|
|
|
|
// Optional. Thumbnail height.
|
|
ThumbHeight int `json:"thumb_height,omitempty"`
|
|
}
|
|
|
|
// Used to avoid endless recursion in MarshalJSON.
|
|
type wrappedInlineQueryResultDocument InlineQueryResultDocument
|
|
|
|
func (r *InlineQueryResultDocument) MarshalJSON() ([]byte, error) {
|
|
id, err := r.id()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return json.Marshal(struct {
|
|
wrappedInlineQueryResultDocument
|
|
Type string `json:"type"`
|
|
ID string `json:"id",hash:"ignore"`
|
|
}{
|
|
wrappedInlineQueryResultDocument: wrappedInlineQueryResultDocument(*r),
|
|
ID: id,
|
|
Type: "document",
|
|
})
|
|
}
|
|
|
|
func (r *InlineQueryResultDocument) id() (string, error) {
|
|
if r.ID == "" {
|
|
return hashInlineQueryResult(r)
|
|
} else {
|
|
return r.ID, nil
|
|
}
|
|
}
|
|
|
|
// InlineQueryResultGif represents a link to an animated GIF file.
|
|
// See also: https://core.telegram.org/bots/api#inlinequeryresultgif
|
|
type InlineQueryResultGif struct {
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
|
// from the other fields and used automatically.
|
|
ID string `json:"id",hash:"ignore"`
|
|
|
|
// A valid URL for the GIF file. File size must not exceed 1MB.
|
|
GifURL string `json:"gif_url"`
|
|
|
|
// URL of the static thumbnail for the result (jpeg or gif).
|
|
ThumbURL string `json:"thumb_url"`
|
|
|
|
// Optional. Width of the GIF.
|
|
GifWidth int `json:"gif_width,omitempty"`
|
|
|
|
// Optional. Height of the GIF.
|
|
GifHeight int `json:"gif_height,omitempty"`
|
|
|
|
// Optional. Title for the result.
|
|
Title string `json:"title,omitempty"`
|
|
|
|
// Optional. Caption of the GIF file to be sent, 0-200 characters.
|
|
Caption string `json:"caption,omitempty"`
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
|
|
// Optional. Content of the message to be sent instead of the audio.
|
|
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
|
|
}
|
|
|
|
// Used to avoid endless recursion in MarshalJSON.
|
|
type wrappedInlineQueryResultGif InlineQueryResultGif
|
|
|
|
func (r *InlineQueryResultGif) MarshalJSON() ([]byte, error) {
|
|
id, err := r.id()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return json.Marshal(struct {
|
|
wrappedInlineQueryResultGif
|
|
Type string `json:"type"`
|
|
ID string `json:"id",hash:"ignore"`
|
|
}{
|
|
wrappedInlineQueryResultGif: wrappedInlineQueryResultGif(*r),
|
|
ID: id,
|
|
Type: "gif",
|
|
})
|
|
}
|
|
|
|
func (r *InlineQueryResultGif) id() (string, error) {
|
|
if r.ID == "" {
|
|
return hashInlineQueryResult(r)
|
|
} else {
|
|
return r.ID, nil
|
|
}
|
|
}
|
|
|
|
// InlineQueryResultLocation represents a location on a map.
|
|
// See also: https://core.telegram.org/bots/api#inlinequeryresultlocation
|
|
type InlineQueryResultLocation struct {
|
|
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
|
// from the other fields and used automatically.
|
|
ID string `json:"id",hash:"ignore"`
|
|
|
|
// Latitude of the location in degrees.
|
|
Latitude float32 `json:"latitude"`
|
|
|
|
// Longitude of the location in degrees.
|
|
Longitude float32 `json:"longitude"`
|
|
|
|
// Location title.
|
|
Title string `json:"title"`
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
|
|
// Optional. Content of the message to be sent instead of the audio.
|
|
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
|
|
|
|
// Optional. Url of the thumbnail for the result.
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
|
|
|
// Optional. Thumbnail width.
|
|
ThumbWidth int `json:"thumb_width,omitempty"`
|
|
|
|
// Optional. Thumbnail height.
|
|
ThumbHeight int `json:"thumb_height,omitempty"`
|
|
}
|
|
|
|
// Used to avoid endless recursion in MarshalJSON.
|
|
type wrappedInlineQueryResultLocation InlineQueryResultLocation
|
|
|
|
func (r *InlineQueryResultLocation) MarshalJSON() ([]byte, error) {
|
|
id, err := r.id()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return json.Marshal(struct {
|
|
wrappedInlineQueryResultLocation
|
|
Type string `json:"type"`
|
|
ID string `json:"id",hash:"ignore"`
|
|
}{
|
|
wrappedInlineQueryResultLocation: wrappedInlineQueryResultLocation(*r),
|
|
ID: id,
|
|
Type: "location",
|
|
})
|
|
}
|
|
|
|
func (r *InlineQueryResultLocation) id() (string, error) {
|
|
if r.ID == "" {
|
|
return hashInlineQueryResult(r)
|
|
} else {
|
|
return r.ID, nil
|
|
}
|
|
}
|
|
|
|
// InlineQueryResultMpeg4Gif represents a link to a video animation
|
|
// (H.264/MPEG-4 AVC video without sound).
|
|
// See also: https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif
|
|
type InlineQueryResultMpeg4Gif struct {
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
|
// from the other fields and used automatically.
|
|
ID string `json:"id",hash:"ignore"`
|
|
|
|
// A valid URL for the MP4 file.
|
|
URL string `json:"mpeg4_url"`
|
|
|
|
// Optional. Video width.
|
|
Width int `json:"mpeg4_width,omitempty"`
|
|
|
|
// Optional. Video height.
|
|
Height int `json:"mpeg4_height,omitempty"`
|
|
|
|
// URL of the static thumbnail (jpeg or gif) for the result.
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
|
|
|
// Optional. Title for the result.
|
|
Title string `json:"title,omitempty"`
|
|
|
|
// Optional. Caption of the MPEG-4 file to be sent, 0-200 characters.
|
|
Caption string `json:"caption,omitempty"`
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
|
|
// Optional. Content of the message to be sent instead of the audio.
|
|
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
|
|
}
|
|
|
|
// Used to avoid endless recursion in MarshalJSON.
|
|
type wrappedInlineQueryResultMpeg4Gif InlineQueryResultMpeg4Gif
|
|
|
|
func (r *InlineQueryResultMpeg4Gif) MarshalJSON() ([]byte, error) {
|
|
id, err := r.id()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return json.Marshal(struct {
|
|
wrappedInlineQueryResultMpeg4Gif
|
|
Type string `json:"type"`
|
|
ID string `json:"id",hash:"ignore"`
|
|
}{
|
|
wrappedInlineQueryResultMpeg4Gif: wrappedInlineQueryResultMpeg4Gif(*r),
|
|
ID: id,
|
|
Type: "mpeg4_gif",
|
|
})
|
|
}
|
|
|
|
func (r *InlineQueryResultMpeg4Gif) id() (string, error) {
|
|
if r.ID == "" {
|
|
return hashInlineQueryResult(r)
|
|
} else {
|
|
return r.ID, nil
|
|
}
|
|
}
|
|
|
|
// InlineQueryResultPhoto represents a link to a photo.
|
|
// See also: https://core.telegram.org/bots/api#inlinequeryresultphoto
|
|
type InlineQueryResultPhoto struct {
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
|
// from the other fields and used automatically.
|
|
ID string `json:"id",hash:"ignore"`
|
|
|
|
// A valid URL of the photo. Photo must be in jpeg format.
|
|
// Photo size must not exceed 5MB.
|
|
PhotoURL string `json:"photo_url"`
|
|
|
|
// URL of the thumbnail for the photo.
|
|
ThumbURL string `json:"thumb_url"`
|
|
|
|
// Optional. Width of the photo.
|
|
PhotoWidth int `json:"photo_width,omitempty"`
|
|
|
|
// Optional. Height of the photo.
|
|
PhotoHeight int `json:"photo_height,omitempty"`
|
|
|
|
// Optional. Title for the result.
|
|
Title string `json:"title,omitempty"`
|
|
|
|
// Optional. Short description of the result.
|
|
Description string `json:"description,omitempty"`
|
|
|
|
// Optional. Caption of the photo to be sent, 0-200 characters.
|
|
Caption string `json:"caption,omitempty"`
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
|
|
// Optional. Content of the message to be sent instead of the audio.
|
|
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
|
|
}
|
|
|
|
// Used to avoid endless recursion in MarshalJSON.
|
|
type wrappedInlineQueryResultPhoto InlineQueryResultPhoto
|
|
|
|
func (r *InlineQueryResultPhoto) MarshalJSON() ([]byte, error) {
|
|
id, err := r.id()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return json.Marshal(struct {
|
|
wrappedInlineQueryResultPhoto
|
|
Type string `json:"type"`
|
|
ID string `json:"id",hash:"ignore"`
|
|
}{
|
|
wrappedInlineQueryResultPhoto: wrappedInlineQueryResultPhoto(*r),
|
|
ID: id,
|
|
Type: "photo",
|
|
})
|
|
}
|
|
|
|
func (r *InlineQueryResultPhoto) id() (string, error) {
|
|
if r.ID == "" {
|
|
return hashInlineQueryResult(r)
|
|
} else {
|
|
return r.ID, nil
|
|
}
|
|
}
|
|
|
|
// InlineQueryResultVenue represents a venue.
|
|
// See also: https://core.telegram.org/bots/api#inlinequeryresultvenue
|
|
type InlineQueryResultVenue struct {
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
|
// from the other fields and used automatically.
|
|
ID string `json:"id",hash:"ignore"`
|
|
|
|
// Latitude of the venue location in degrees.
|
|
Latitude float32 `json:"latitude"`
|
|
|
|
// Longitude of the venue location in degrees.
|
|
Longitude float32 `json:"longitude"`
|
|
|
|
// Title of the venue.
|
|
Title string `json:"title"`
|
|
|
|
// Address of the venue.
|
|
Address string `json:"address"`
|
|
|
|
// Optional. Foursquare identifier of the venue if known.
|
|
FoursquareID string `json:"foursquare_id,omitempty"`
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
|
|
// Optional. Content of the message to be sent instead of the audio.
|
|
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
|
|
|
|
// Optional. Url of the thumbnail for the result.
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
|
|
|
// Optional. Thumbnail width.
|
|
ThumbWidth int `json:"thumb_width,omitempty"`
|
|
|
|
// Optional. Thumbnail height.
|
|
ThumbHeight int `json:"thumb_height,omitempty"`
|
|
}
|
|
|
|
// Used to avoid endless recursion in MarshalJSON.
|
|
type wrappedInlineQueryResultVenue InlineQueryResultVenue
|
|
|
|
func (r *InlineQueryResultVenue) MarshalJSON() ([]byte, error) {
|
|
id, err := r.id()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return json.Marshal(struct {
|
|
wrappedInlineQueryResultVenue
|
|
Type string `json:"type"`
|
|
ID string `json:"id",hash:"ignore"`
|
|
}{
|
|
wrappedInlineQueryResultVenue: wrappedInlineQueryResultVenue(*r),
|
|
ID: id,
|
|
Type: "venue",
|
|
})
|
|
}
|
|
|
|
func (r *InlineQueryResultVenue) id() (string, error) {
|
|
if r.ID == "" {
|
|
return hashInlineQueryResult(r)
|
|
} else {
|
|
return r.ID, nil
|
|
}
|
|
}
|
|
|
|
// InlineQueryResultVideo represents a link to a page containing an embedded
|
|
// video player or a video file.
|
|
// See also: https://core.telegram.org/bots/api#inlinequeryresultvideo
|
|
type InlineQueryResultVideo struct {
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
|
// from the other fields and used automatically.
|
|
ID string `json:"id",hash:"ignore"`
|
|
|
|
// A valid URL for the embedded video player or video file.
|
|
VideoURL string `json:"video_url"`
|
|
|
|
// Mime type of the content of video url, “text/html” or “video/mp4”.
|
|
MimeType string `json:"mime_type"`
|
|
|
|
// URL of the thumbnail (jpeg only) for the video.
|
|
ThumbURL string `json:"thumb_url"`
|
|
|
|
// Title for the result.
|
|
Title string `json:"title"`
|
|
|
|
// Optional. Caption of the video to be sent, 0-200 characters.
|
|
Caption string `json:"caption,omitempty"`
|
|
|
|
// Optional. Video width.
|
|
VideoWidth int `json:"video_width,omitempty"`
|
|
|
|
// Optional. Video height.
|
|
VideoHeight int `json:"video_height,omitempty"`
|
|
|
|
// Optional. Video duration in seconds.
|
|
VideoDuration int `json:"video_duration,omitempty"`
|
|
|
|
// Optional. Short description of the result.
|
|
Description string `json:"description,omitempty"`
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
|
|
// Optional. Content of the message to be sent instead of the audio.
|
|
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
|
|
}
|
|
|
|
// Used to avoid endless recursion in MarshalJSON.
|
|
type wrappedInlineQueryResultVideo InlineQueryResultVideo
|
|
|
|
func (r *InlineQueryResultVideo) MarshalJSON() ([]byte, error) {
|
|
id, err := r.id()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return json.Marshal(struct {
|
|
wrappedInlineQueryResultVideo
|
|
Type string `json:"type"`
|
|
ID string `json:"id",hash:"ignore"`
|
|
}{
|
|
wrappedInlineQueryResultVideo: wrappedInlineQueryResultVideo(*r),
|
|
ID: id,
|
|
Type: "video",
|
|
})
|
|
}
|
|
|
|
func (r *InlineQueryResultVideo) id() (string, error) {
|
|
if r.ID == "" {
|
|
return hashInlineQueryResult(r)
|
|
} else {
|
|
return r.ID, nil
|
|
}
|
|
}
|
|
|
|
// InlineQueryResultVoice represents a link to a voice recording in a
|
|
// .ogg container encoded with OPUS.
|
|
// See also: https://core.telegram.org/bots/api#inlinequeryresultvoice
|
|
type InlineQueryResultVoice struct {
|
|
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
|
// from the other fields and used automatically.
|
|
ID string `json:"id",hash:"ignore"`
|
|
|
|
// A valid URL for the voice recording.
|
|
VoiceURL string `json:"voice_url"`
|
|
|
|
// Recording title.
|
|
Title string `json:"title"`
|
|
|
|
// Optional. Recording duration in seconds.
|
|
VoiceDuration int `json:"voice_duration"`
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
|
|
// Optional. Content of the message to be sent instead of the audio.
|
|
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
|
|
}
|
|
|
|
// Used to avoid endless recursion in MarshalJSON.
|
|
type wrappedInlineQueryResultVoice InlineQueryResultVoice
|
|
|
|
func (r *InlineQueryResultVoice) MarshalJSON() ([]byte, error) {
|
|
id, err := r.id()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return json.Marshal(struct {
|
|
wrappedInlineQueryResultVoice
|
|
Type string `json:"type"`
|
|
ID string `json:"id",hash:"ignore"`
|
|
}{
|
|
wrappedInlineQueryResultVoice: wrappedInlineQueryResultVoice(*r),
|
|
ID: id,
|
|
Type: "voice",
|
|
})
|
|
}
|
|
|
|
func (r *InlineQueryResultVoice) id() (string, error) {
|
|
if r.ID == "" {
|
|
return hashInlineQueryResult(r)
|
|
} else {
|
|
return r.ID, nil
|
|
}
|
|
}
|