2016-06-26 14:05:37 +00:00
|
|
|
package telebot
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// ResultBase must be embedded into all IQRs.
|
|
|
|
type ResultBase struct {
|
2016-06-26 14:05:37 +00:00
|
|
|
// Unique identifier for this result, 1-64 Bytes.
|
|
|
|
// If left unspecified, a 64-bit FNV-1 hash will be calculated
|
2017-12-26 22:39:15 +00:00
|
|
|
ID string `json:"id"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
2016-11-10 17:52:45 +00:00
|
|
|
// Ignore. This field gets set automatically.
|
2017-12-26 22:39:15 +00:00
|
|
|
Type string `json:"type"`
|
2017-11-24 14:08:23 +00:00
|
|
|
|
2021-07-07 13:00:51 +00:00
|
|
|
// Optional. Send Markdown or HTML, if you want Telegram apps to show
|
|
|
|
// bold, italic, fixed-width text or inline URLs in the media caption.
|
|
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
|
|
|
2017-11-29 20:14:25 +00:00
|
|
|
// Optional. Content of the message to be sent.
|
2021-07-25 12:42:40 +00:00
|
|
|
Content InputMessageContent `json:"input_message_content,omitempty"`
|
2017-11-24 14:08:23 +00:00
|
|
|
|
|
|
|
// Optional. Inline keyboard attached to the message.
|
|
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
2016-11-10 17:52:45 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// ResultID returns ResultBase.ID.
|
|
|
|
func (r *ResultBase) ResultID() string {
|
|
|
|
return r.ID
|
2016-11-10 17:52:45 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// SetResultID sets ResultBase.ID.
|
|
|
|
func (r *ResultBase) SetResultID(id string) {
|
|
|
|
r.ID = id
|
2016-11-10 17:52:45 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 13:00:51 +00:00
|
|
|
// SetParseMode sets ResultBase.ParseMode.
|
|
|
|
func (r *ResultBase) SetParseMode(mode ParseMode) {
|
|
|
|
r.ParseMode = mode
|
|
|
|
}
|
|
|
|
|
2019-09-30 15:42:02 +00:00
|
|
|
// SetContent sets ResultBase.Content.
|
|
|
|
func (r *ResultBase) SetContent(content InputMessageContent) {
|
2021-07-25 12:42:40 +00:00
|
|
|
r.Content = content
|
2019-09-30 15:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetReplyMarkup sets ResultBase.ReplyMarkup.
|
|
|
|
func (r *ResultBase) SetReplyMarkup(keyboard [][]InlineButton) {
|
|
|
|
r.ReplyMarkup = &InlineKeyboardMarkup{InlineKeyboard: keyboard}
|
|
|
|
}
|
|
|
|
|
2021-07-07 13:00:51 +00:00
|
|
|
func (r *ResultBase) Process(b *Bot) {
|
|
|
|
if r.ParseMode == ModeDefault {
|
|
|
|
r.ParseMode = b.parseMode
|
|
|
|
}
|
|
|
|
if r.Content != nil {
|
2021-07-25 12:42:40 +00:00
|
|
|
c, ok := r.Content.(*InputTextMessageContent)
|
2021-07-07 13:00:51 +00:00
|
|
|
if ok && c.ParseMode == ModeDefault {
|
|
|
|
c.ParseMode = r.ParseMode
|
|
|
|
}
|
|
|
|
}
|
2017-12-26 22:39:15 +00:00
|
|
|
if r.ReplyMarkup != nil {
|
|
|
|
processButtons(r.ReplyMarkup.InlineKeyboard)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// ArticleResult represents a link to an article or web page.
|
|
|
|
type ArticleResult struct {
|
|
|
|
ResultBase
|
2016-11-10 17:52:45 +00:00
|
|
|
|
2016-06-26 14:05:37 +00:00
|
|
|
// Title of the result.
|
|
|
|
Title string `json:"title"`
|
|
|
|
|
|
|
|
// Message text. Shortcut (and mutually exclusive to) specifying
|
|
|
|
// InputMessageContent.
|
|
|
|
Text string `json:"message_text,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"`
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// Optional. URL of the thumbnail for the result.
|
2016-06-26 14:05:37 +00:00
|
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
2019-10-28 19:22:30 +00:00
|
|
|
|
|
|
|
// Optional. Width of the thumbnail for the result.
|
|
|
|
ThumbWidth int `json:"thumb_width,omitempty"`
|
|
|
|
|
|
|
|
// Optional. Height of the thumbnail for the result.
|
|
|
|
ThumbHeight int `json:"thumb_height,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// AudioResult represents a link to an mp3 audio file.
|
|
|
|
type AudioResult struct {
|
|
|
|
ResultBase
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Title.
|
|
|
|
Title string `json:"title"`
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// A valid URL for the audio file.
|
|
|
|
URL string `json:"audio_url"`
|
|
|
|
|
2016-06-26 14:05:37 +00:00
|
|
|
// Optional. Performer.
|
|
|
|
Performer string `json:"performer,omitempty"`
|
|
|
|
|
|
|
|
// Optional. Audio duration in seconds.
|
|
|
|
Duration int `json:"audio_duration,omitempty"`
|
2017-11-26 08:17:52 +00:00
|
|
|
|
2019-10-28 19:22:30 +00:00
|
|
|
// Optional. Caption, 0-1024 characters.
|
|
|
|
Caption string `json:"caption,omitempty"`
|
|
|
|
|
2017-11-26 08:17:52 +00:00
|
|
|
// If Cache != "", it'll be used instead
|
|
|
|
Cache string `json:"audio_file_id,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 13:00:51 +00:00
|
|
|
// ContactResult represents a contact with a phone number.
|
2017-11-24 14:08:23 +00:00
|
|
|
type ContactResult struct {
|
|
|
|
ResultBase
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Contact's phone number.
|
|
|
|
PhoneNumber string `json:"phone_number"`
|
|
|
|
|
2019-10-28 19:22:30 +00:00
|
|
|
// Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes.
|
|
|
|
VCard string `json:"vcard,omitempty"`
|
|
|
|
|
2016-06-26 14:05:37 +00:00
|
|
|
// Contact's first name.
|
|
|
|
FirstName string `json:"first_name"`
|
|
|
|
|
|
|
|
// Optional. Contact's last name.
|
|
|
|
LastName string `json:"last_name,omitempty"`
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// Optional. URL of the thumbnail for the result.
|
2016-06-26 14:05:37 +00:00
|
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
2019-10-28 19:22:30 +00:00
|
|
|
|
|
|
|
// Optional. Width of the thumbnail for the result.
|
|
|
|
ThumbWidth int `json:"thumb_width,omitempty"`
|
|
|
|
|
|
|
|
// Optional. Height of the thumbnail for the result.
|
|
|
|
ThumbHeight int `json:"thumb_height,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// DocumentResult represents a link to a file.
|
|
|
|
type DocumentResult struct {
|
|
|
|
ResultBase
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Title for the result.
|
|
|
|
Title string `json:"title"`
|
|
|
|
|
|
|
|
// A valid URL for the file
|
2017-11-24 14:08:23 +00:00
|
|
|
URL string `json:"document_url"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Mime type of the content of the file, either “application/pdf” or
|
|
|
|
// “application/zip”.
|
2017-11-24 14:08:23 +00:00
|
|
|
MIME string `json:"mime_type"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// 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. URL of the thumbnail (jpeg only) for the file.
|
|
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
2017-11-26 08:17:52 +00:00
|
|
|
|
2019-10-28 19:22:30 +00:00
|
|
|
// Optional. Width of the thumbnail for the result.
|
|
|
|
ThumbWidth int `json:"thumb_width,omitempty"`
|
|
|
|
|
|
|
|
// Optional. Height of the thumbnail for the result.
|
|
|
|
ThumbHeight int `json:"thumb_height,omitempty"`
|
|
|
|
|
2017-11-26 08:17:52 +00:00
|
|
|
// If Cache != "", it'll be used instead
|
|
|
|
Cache string `json:"document_file_id,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// GifResult represents a link to an animated GIF file.
|
|
|
|
type GifResult struct {
|
|
|
|
ResultBase
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// A valid URL for the GIF file. File size must not exceed 1MB.
|
2017-11-24 14:08:23 +00:00
|
|
|
URL string `json:"gif_url"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Optional. Width of the GIF.
|
2017-11-24 14:08:23 +00:00
|
|
|
Width int `json:"gif_width,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Optional. Height of the GIF.
|
2017-11-24 14:08:23 +00:00
|
|
|
Height int `json:"gif_height,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
2019-10-28 19:22:30 +00:00
|
|
|
// Optional. Duration of the GIF.
|
|
|
|
Duration int `json:"gif_duration,omitempty"`
|
|
|
|
|
2020-06-07 18:56:54 +00:00
|
|
|
// URL of the static thumbnail for the result (jpeg or gif).
|
|
|
|
ThumbURL string `json:"thumb_url"`
|
|
|
|
|
|
|
|
// Optional. MIME type of the thumbnail, must be one of
|
|
|
|
// “image/jpeg”, “image/gif”, or “video/mp4”.
|
|
|
|
ThumbMIME string `json:"thumb_mime_type,omitempty"`
|
|
|
|
|
2016-06-26 14:05:37 +00:00
|
|
|
// 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"`
|
|
|
|
|
2017-11-26 08:17:52 +00:00
|
|
|
// If Cache != "", it'll be used instead
|
|
|
|
Cache string `json:"gif_file_id,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// LocationResult represents a location on a map.
|
|
|
|
type LocationResult struct {
|
|
|
|
ResultBase
|
2016-06-26 14:05:37 +00:00
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
Location
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Location title.
|
|
|
|
Title string `json:"title"`
|
|
|
|
|
|
|
|
// Optional. Url of the thumbnail for the result.
|
|
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
|
|
|
}
|
|
|
|
|
2021-07-07 13:00:51 +00:00
|
|
|
// Mpeg4GifResult represents a link to a video animation
|
2016-06-26 14:05:37 +00:00
|
|
|
// (H.264/MPEG-4 AVC video without sound).
|
2017-11-24 14:08:23 +00:00
|
|
|
type Mpeg4GifResult struct {
|
|
|
|
ResultBase
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// 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"`
|
|
|
|
|
2019-10-28 19:22:30 +00:00
|
|
|
// Optional. Video duration.
|
|
|
|
Duration int `json:"mpeg4_duration,omitempty"`
|
|
|
|
|
2016-06-26 14:05:37 +00:00
|
|
|
// URL of the static thumbnail (jpeg or gif) for the result.
|
|
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
|
|
|
|
2020-06-07 18:56:54 +00:00
|
|
|
// Optional. MIME type of the thumbnail, must be one of
|
|
|
|
// “image/jpeg”, “image/gif”, or “video/mp4”.
|
|
|
|
ThumbMIME string `json:"thumb_mime_type,omitempty"`
|
|
|
|
|
2016-06-26 14:05:37 +00:00
|
|
|
// 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"`
|
2017-11-26 08:17:52 +00:00
|
|
|
|
|
|
|
// If Cache != "", it'll be used instead
|
|
|
|
Cache string `json:"mpeg4_file_id,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 13:00:51 +00:00
|
|
|
// PhotoResult represents a link to a photo.
|
2017-11-24 14:08:23 +00:00
|
|
|
type PhotoResult struct {
|
|
|
|
ResultBase
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// A valid URL of the photo. Photo must be in jpeg format.
|
|
|
|
// Photo size must not exceed 5MB.
|
2017-11-24 14:08:23 +00:00
|
|
|
URL string `json:"photo_url"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Optional. Width of the photo.
|
2017-11-24 14:08:23 +00:00
|
|
|
Width int `json:"photo_width,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Optional. Height of the photo.
|
2017-11-24 14:08:23 +00:00
|
|
|
Height int `json:"photo_height,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// 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"`
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// URL of the thumbnail for the photo.
|
|
|
|
ThumbURL string `json:"thumb_url"`
|
2017-11-26 08:17:52 +00:00
|
|
|
|
|
|
|
// If Cache != "", it'll be used instead
|
|
|
|
Cache string `json:"photo_file_id,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// VenueResult represents a venue.
|
|
|
|
type VenueResult struct {
|
|
|
|
ResultBase
|
2016-06-26 14:05:37 +00:00
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
Location
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// 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"`
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// Optional. URL of the thumbnail for the result.
|
2016-06-26 14:05:37 +00:00
|
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
2019-10-28 19:22:30 +00:00
|
|
|
|
|
|
|
// Optional. Width of the thumbnail for the result.
|
|
|
|
ThumbWidth int `json:"thumb_width,omitempty"`
|
|
|
|
|
|
|
|
// Optional. Height of the thumbnail for the result.
|
|
|
|
ThumbHeight int `json:"thumb_height,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// VideoResult represents a link to a page containing an embedded
|
2016-06-26 14:05:37 +00:00
|
|
|
// video player or a video file.
|
2017-11-24 14:08:23 +00:00
|
|
|
type VideoResult struct {
|
|
|
|
ResultBase
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// A valid URL for the embedded video player or video file.
|
2017-11-24 14:08:23 +00:00
|
|
|
URL string `json:"video_url"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Mime type of the content of video url, “text/html” or “video/mp4”.
|
2017-11-24 14:08:23 +00:00
|
|
|
MIME string `json:"mime_type"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// 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.
|
2017-11-24 14:08:23 +00:00
|
|
|
Width int `json:"video_width,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Optional. Video height.
|
2017-11-24 14:08:23 +00:00
|
|
|
Height int `json:"video_height,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Optional. Video duration in seconds.
|
2017-11-24 14:08:23 +00:00
|
|
|
Duration int `json:"video_duration,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Optional. Short description of the result.
|
|
|
|
Description string `json:"description,omitempty"`
|
2017-11-26 08:17:52 +00:00
|
|
|
|
|
|
|
// If Cache != "", it'll be used instead
|
|
|
|
Cache string `json:"video_file_id,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 14:08:23 +00:00
|
|
|
// VoiceResult represents a link to a voice recording in an .ogg
|
|
|
|
// container encoded with OPUS.
|
|
|
|
type VoiceResult struct {
|
|
|
|
ResultBase
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// A valid URL for the voice recording.
|
2017-11-24 14:08:23 +00:00
|
|
|
URL string `json:"voice_url"`
|
2016-06-26 14:05:37 +00:00
|
|
|
|
|
|
|
// Recording title.
|
|
|
|
Title string `json:"title"`
|
|
|
|
|
|
|
|
// Optional. Recording duration in seconds.
|
2017-11-24 14:08:23 +00:00
|
|
|
Duration int `json:"voice_duration"`
|
2017-11-26 08:17:52 +00:00
|
|
|
|
2019-10-28 19:22:30 +00:00
|
|
|
// Optional. Caption, 0-1024 characters.
|
|
|
|
Caption string `json:"caption,omitempty"`
|
|
|
|
|
2017-11-26 08:17:52 +00:00
|
|
|
// If Cache != "", it'll be used instead
|
|
|
|
Cache string `json:"voice_file_id,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// StickerResult represents an inline cached sticker response.
|
|
|
|
type StickerResult struct {
|
|
|
|
ResultBase
|
|
|
|
|
|
|
|
// If Cache != "", it'll be used instead
|
|
|
|
Cache string `json:"sticker_file_id,omitempty"`
|
2016-06-26 14:05:37 +00:00
|
|
|
}
|