FILE / ScuroNeko/Laniakea

tgapi/attachments_methods.go

Исходный файл и его история в репозитории.
FILE 29b208eeec6d77c16e9b5c5a4c4d280b36c10dea
Files
Laniakea/tgapi/attachments_methods.go
T
ScuroNeko 29b208eeec
Golang lint / lint (push) Successful in 11m32s
(new): v1.2 release
2026-08-19 14:58:25 +03:00

816 lines
49 KiB
Go

package tgapi
import "context"
// SendPhoto holds parameters for the sendPhoto method.
// Since: Bot API 1.0
// See https://core.telegram.org/bots/api#sendphoto
type SendPhoto struct {
// BusinessConnectionID Optional. Unique identifier of the business connection on behalf of which the
// message will be sent
BusinessConnectionID string `json:"business_connection_id,omitempty"`
// ChatID Required. Unique identifier for the target chat or username of the target bot, supergroup or
// channel in the format @username
ChatID int64 `json:"chat_id"`
// MessageThreadID Optional. Unique identifier for the target message thread (topic) of a forum; for forum
// supergroups and private chats of bots with forum topic mode enabled only
MessageThreadID int `json:"message_thread_id,omitempty"`
// DirectMessagesTopicID Optional. Identifier of the direct messages topic to which the message will be
// sent; required if the message is sent to a direct messages chat
DirectMessagesTopicID int `json:"direct_messages_topic_id,omitempty"`
// ReceiverUserID identifies the user who can see the ephemeral message.
ReceiverUserID int64 `json:"receiver_user_id,omitempty"` // Since: Bot API 10.2
// CallbackQueryID identifies the callback query that triggered an ephemeral response.
CallbackQueryID string `json:"callback_query_id,omitempty"` // Since: Bot API 10.2
// Photo Required. Photo to send. Pass a file_id as String to send a photo that exists on the Telegram
// servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or
// upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width
// and height must not exceed 10000 in total. Width and height ratio must be at most 20. More information on
// Sending Files »
Photo string `json:"photo"`
// Caption Optional. Photo caption (may also be used when resending photos by file_id), 0-1024 characters
// after entities parsing
Caption string `json:"caption,omitempty"`
// ParseMode Optional. Mode for parsing entities in the photo caption. See formatting options for more
// details.
ParseMode ParseMode `json:"parse_mode,omitempty"`
// CaptionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which
// can be specified instead of parse_mode
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// ShowCaptionAboveMedia Optional. Pass True if the caption must be shown above the message media
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// HasSpoiler Optional. Pass True if the photo needs to be covered with a spoiler animation
HasSpoiler bool `json:"has_spoiler,omitempty"`
// DisableNotifications Optional. Sends the message silently. Users will receive a notification with no
// sound.
DisableNotifications bool `json:"disable_notification,omitempty"`
// ProtectContent Optional. Protects the contents of the sent message from forwarding and saving
ProtectContent bool `json:"protect_content,omitempty"`
// AllowPaidBroadcast Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting
// limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's
// balance.
AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"`
// MessageEffectID Optional. Unique identifier of the message effect to be added to the message; for private
// chats only
MessageEffectID string `json:"message_effect_id,omitempty"`
// SuggestedPostParameters Optional. A JSON-serialized object containing the parameters of the suggested
// post to send; for direct messages chats only. If the message is sent as a reply to another suggested
// post, then that suggested post is automatically declined.
SuggestedPostParameters *SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
// ReplyParameters Optional. Description of the message to reply to
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
// ReplyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard,
// custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendPhoto sends a photo.
// Since: Bot API 1.0
// See https://core.telegram.org/bots/api#sendphoto
func (api *API) SendPhoto(params SendPhoto) (Message, error) {
req := NewRequestWithChatID[Message]("sendPhoto", params, params.ChatID)
return req.Do(api)
}
// SendPhotoWithContext is the context-aware variant of SendPhoto.
// Since: Bot API 1.0
// It executes the same request but uses ctx for cancellation and deadlines.
// See https://core.telegram.org/bots/api#sendphoto
func (api *API) SendPhotoWithContext(ctx context.Context, params SendPhoto) (Message, error) {
req := NewRequestWithChatID[Message]("sendPhoto", params, params.ChatID)
return req.DoWithContext(ctx, api)
}
// SendAudio holds parameters for the sendAudio method.
// Since: Bot API 1.2
// See https://core.telegram.org/bots/api#sendaudio
type SendAudio struct {
// BusinessConnectionID Optional. Unique identifier of the business connection on behalf of which the
// message will be sent
BusinessConnectionID string `json:"business_connection_id,omitempty"`
// ChatID Required. Unique identifier for the target chat or username of the target bot, supergroup or
// channel in the format @username
ChatID int64 `json:"chat_id"`
// MessageThreadID Optional. Unique identifier for the target message thread (topic) of a forum; for forum
// supergroups and private chats of bots with forum topic mode enabled only
MessageThreadID int `json:"message_thread_id,omitempty"`
// DirectMessagesTopicID Optional. Identifier of the direct messages topic to which the message will be
// sent; required if the message is sent to a direct messages chat
DirectMessagesTopicID int `json:"direct_messages_topic_id,omitempty"`
// ReceiverUserID identifies the user who can see the ephemeral message.
ReceiverUserID int64 `json:"receiver_user_id,omitempty"` // Since: Bot API 10.2
// CallbackQueryID identifies the callback query that triggered an ephemeral response.
CallbackQueryID string `json:"callback_query_id,omitempty"` // Since: Bot API 10.2
// Audio Required. Audio file to send. Pass a file_id as String to send an audio file that exists on the
// Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the
// Internet, or upload a new one using multipart/form-data. More information on Sending Files »
Audio string `json:"audio"`
// Caption Optional. Audio caption, 0-1024 characters after entities parsing
Caption string `json:"caption,omitempty"`
// ParseMode Optional. Mode for parsing entities in the audio caption. See formatting options for more
// details.
ParseMode ParseMode `json:"parse_mode,omitempty"`
// CaptionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which
// can be specified instead of parse_mode
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Duration Optional. Duration of the audio in seconds
Duration int `json:"duration,omitempty"`
// Performer Optional. Performer
Performer string `json:"performer,omitempty"`
// Title Optional. Track name
Title string `json:"title,omitempty"`
// Thumbnail Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
// supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's
// width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data.
// Thumbnails can't be reused and can be only uploaded as a new file, so you can pass
// “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under
// <file_attach_name>. More information on Sending Files »
Thumbnail string `json:"thumbnail,omitempty"`
// DisableNotification Optional. Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ProtectContent Optional. Protects the contents of the sent message from forwarding and saving
ProtectContent bool `json:"protect_content,omitempty"`
// AllowPaidBroadcast Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting
// limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's
// balance.
AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"`
// MessageEffectID Optional. Unique identifier of the message effect to be added to the message; for private
// chats only
MessageEffectID string `json:"message_effect_id,omitempty"`
// SuggestedPostParameters Optional. A JSON-serialized object containing the parameters of the suggested
// post to send; for direct messages chats only. If the message is sent as a reply to another suggested
// post, then that suggested post is automatically declined.
SuggestedPostParameters *SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
// ReplyParameters Optional. Description of the message to reply to
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
// ReplyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard,
// custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendAudio sends an audio file.
// Since: Bot API 1.2
// See https://core.telegram.org/bots/api#sendaudio
func (api *API) SendAudio(params SendAudio) (Message, error) {
req := NewRequestWithChatID[Message]("sendAudio", params, params.ChatID)
return req.Do(api)
}
// SendAudioWithContext is the context-aware variant of SendAudio.
// Since: Bot API 1.2
// It executes the same request but uses ctx for cancellation and deadlines.
// See https://core.telegram.org/bots/api#sendaudio
func (api *API) SendAudioWithContext(ctx context.Context, params SendAudio) (Message, error) {
req := NewRequestWithChatID[Message]("sendAudio", params, params.ChatID)
return req.DoWithContext(ctx, api)
}
// SendDocument holds parameters for the sendDocument method.
// Since: Bot API 1.0
// See https://core.telegram.org/bots/api#senddocument
type SendDocument struct {
// BusinessConnectionID Optional. Unique identifier of the business connection on behalf of which the
// message will be sent
BusinessConnectionID string `json:"business_connection_id,omitempty"`
// ChatID Required. Unique identifier for the target chat or username of the target bot, supergroup or
// channel in the format @username
ChatID int64 `json:"chat_id"`
// MessageThreadID Optional. Unique identifier for the target message thread (topic) of a forum; for forum
// supergroups and private chats of bots with forum topic mode enabled only
MessageThreadID int `json:"message_thread_id,omitempty"`
// DirectMessagesTopicID Optional. Identifier of the direct messages topic to which the message will be
// sent; required if the message is sent to a direct messages chat
DirectMessagesTopicID int `json:"direct_messages_topic_id,omitempty"`
// ReceiverUserID identifies the user who can see the ephemeral message.
ReceiverUserID int64 `json:"receiver_user_id,omitempty"` // Since: Bot API 10.2
// CallbackQueryID identifies the callback query that triggered an ephemeral response.
CallbackQueryID string `json:"callback_query_id,omitempty"` // Since: Bot API 10.2
// Document Required. File to send. Pass a file_id as String to send a file that exists on the Telegram
// servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or
// upload a new one using multipart/form-data. More information on Sending Files »
Document string `json:"document"`
// Thumbnail Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
// supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's
// width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data.
// Thumbnails can't be reused and can be only uploaded as a new file, so you can pass
// “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under
// <file_attach_name>. More information on Sending Files »
Thumbnail string `json:"thumbnail,omitempty"`
// Caption Optional. Document caption (may also be used when resending documents by file_id), 0-1024
// characters after entities parsing
Caption string `json:"caption,omitempty"`
// ParseMode Optional. Mode for parsing entities in the document caption. See formatting options for more
// details.
ParseMode ParseMode `json:"parse_mode,omitempty"`
// CaptionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which
// can be specified instead of parse_mode
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// DisableContentTypeDetection Optional. Disables automatic server-side content type detection for files
// uploaded using multipart/form-data
DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"`
// DisableNotification Optional. Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ProtectContent Optional. Protects the contents of the sent message from forwarding and saving
ProtectContent bool `json:"protect_content,omitempty"`
// AllowPaidBroadcast Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting
// limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's
// balance.
AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"`
// MessageEffectID Optional. Unique identifier of the message effect to be added to the message; for private
// chats only
MessageEffectID string `json:"message_effect_id,omitempty"`
// SuggestedPostParameters Optional. A JSON-serialized object containing the parameters of the suggested
// post to send; for direct messages chats only. If the message is sent as a reply to another suggested
// post, then that suggested post is automatically declined.
SuggestedPostParameters *SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
// ReplyParameters Optional. Description of the message to reply to
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
// ReplyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard,
// custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendDocument sends a document.
// Since: Bot API 1.0
// See https://core.telegram.org/bots/api#senddocument
func (api *API) SendDocument(params SendDocument) (Message, error) {
req := NewRequestWithChatID[Message]("sendDocument", params, params.ChatID)
return req.Do(api)
}
// SendDocumentWithContext is the context-aware variant of SendDocument.
// Since: Bot API 1.0
// It executes the same request but uses ctx for cancellation and deadlines.
// See https://core.telegram.org/bots/api#senddocument
func (api *API) SendDocumentWithContext(ctx context.Context, params SendDocument) (Message, error) {
req := NewRequestWithChatID[Message]("sendDocument", params, params.ChatID)
return req.DoWithContext(ctx, api)
}
// SendVideo holds parameters for the sendVideo method.
// Since: Bot API 1.0
// See https://core.telegram.org/bots/api#sendvideo
type SendVideo struct {
// BusinessConnectionID Optional. Unique identifier of the business connection on behalf of which the
// message will be sent
BusinessConnectionID string `json:"business_connection_id,omitempty"`
// ChatID Required. Unique identifier for the target chat or username of the target bot, supergroup or
// channel in the format @username
ChatID int64 `json:"chat_id"`
// MessageThreadID Optional. Unique identifier for the target message thread (topic) of a forum; for forum
// supergroups and private chats of bots with forum topic mode enabled only
MessageThreadID int `json:"message_thread_id,omitempty"`
// DirectMessagesTopicID Optional. Identifier of the direct messages topic to which the message will be
// sent; required if the message is sent to a direct messages chat
DirectMessagesTopicID int `json:"direct_messages_topic_id,omitempty"`
// ReceiverUserID identifies the user who can see the ephemeral message.
ReceiverUserID int64 `json:"receiver_user_id,omitempty"` // Since: Bot API 10.2
// CallbackQueryID identifies the callback query that triggered an ephemeral response.
CallbackQueryID string `json:"callback_query_id,omitempty"` // Since: Bot API 10.2
// Video Required. Video to send. Pass a file_id as String to send a video that exists on the Telegram
// servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or
// upload a new video using multipart/form-data. More information on Sending Files »
Video string `json:"video"`
// Thumbnail Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
// supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's
// width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data.
// Thumbnails can't be reused and can be only uploaded as a new file, so you can pass
// “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under
// <file_attach_name>. More information on Sending Files »
Thumbnail string `json:"thumbnail,omitempty"`
// Duration Optional. Duration of sent video in seconds
Duration int `json:"duration,omitempty"`
// Width Optional. Video width
Width int `json:"width,omitempty"`
// Height Optional. Video height
Height int `json:"height,omitempty"`
// Cover Optional. Cover for the video in the message. Pass a file_id to send a file that exists on the
// Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass
// “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name>
// name. More information on Sending Files »
Cover string `json:"cover,omitempty"`
// StartTimestamp Optional. Start timestamp for the video in the message
StartTimestamp int `json:"start_timestamp,omitempty"`
// Caption Optional. Video caption (may also be used when resending videos by file_id), 0-1024 characters
// after entities parsing
Caption string `json:"caption,omitempty"`
// ParseMode Optional. Mode for parsing entities in the video caption. See formatting options for more
// details.
ParseMode ParseMode `json:"parse_mode,omitempty"`
// CaptionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which
// can be specified instead of parse_mode
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// ShowCaptionAboveMedia Optional. Pass True if the caption must be shown above the message media
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// HasSpoiler Optional. Pass True if the video needs to be covered with a spoiler animation
HasSpoiler bool `json:"has_spoiler,omitempty"`
// SupportsStreaming Optional. Pass True if the uploaded video is suitable for streaming
SupportsStreaming bool `json:"supports_streaming,omitempty"`
// DisableNotification Optional. Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ProtectContent Optional. Protects the contents of the sent message from forwarding and saving
ProtectContent bool `json:"protect_content,omitempty"`
// AllowPaidBroadcast Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting
// limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's
// balance.
AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"`
// MessageEffectID Optional. Unique identifier of the message effect to be added to the message; for private
// chats only
MessageEffectID string `json:"message_effect_id,omitempty"`
// SuggestedPostParameters Optional. A JSON-serialized object containing the parameters of the suggested
// post to send; for direct messages chats only. If the message is sent as a reply to another suggested
// post, then that suggested post is automatically declined.
SuggestedPostParameters *SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
// ReplyParameters Optional. Description of the message to reply to
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
// ReplyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard,
// custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendVideo sends a video.
// Since: Bot API 1.0
// See https://core.telegram.org/bots/api#sendvideo
func (api *API) SendVideo(params SendVideo) (Message, error) {
req := NewRequestWithChatID[Message]("sendVideo", params, params.ChatID)
return req.Do(api)
}
// SendVideoWithContext is the context-aware variant of SendVideo.
// Since: Bot API 1.0
// It executes the same request but uses ctx for cancellation and deadlines.
// See https://core.telegram.org/bots/api#sendvideo
func (api *API) SendVideoWithContext(ctx context.Context, params SendVideo) (Message, error) {
req := NewRequestWithChatID[Message]("sendVideo", params, params.ChatID)
return req.DoWithContext(ctx, api)
}
// SendAnimation holds parameters for the sendAnimation method.
// Since: Bot API 4.0
// See https://core.telegram.org/bots/api#sendanimation
type SendAnimation struct {
// BusinessConnectionID Optional. Unique identifier of the business connection on behalf of which the
// message will be sent
BusinessConnectionID string `json:"business_connection_id,omitempty"`
// ChatID Required. Unique identifier for the target chat or username of the target bot, supergroup or
// channel in the format @username
ChatID int64 `json:"chat_id"`
// MessageThreadID Optional. Unique identifier for the target message thread (topic) of a forum; for forum
// supergroups and private chats of bots with forum topic mode enabled only
MessageThreadID int `json:"message_thread_id,omitempty"`
// DirectMessagesTopicID Optional. Identifier of the direct messages topic to which the message will be
// sent; required if the message is sent to a direct messages chat
DirectMessagesTopicID int `json:"direct_messages_topic_id,omitempty"`
// ReceiverUserID identifies the user who can see the ephemeral message.
ReceiverUserID int64 `json:"receiver_user_id,omitempty"` // Since: Bot API 10.2
// CallbackQueryID identifies the callback query that triggered an ephemeral response.
CallbackQueryID string `json:"callback_query_id,omitempty"` // Since: Bot API 10.2
// Animation Required. Animation to send. Pass a file_id as String to send an animation that exists on the
// Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the
// Internet, or upload a new animation using multipart/form-data. More information on Sending Files »
Animation string `json:"animation"`
// Thumbnail Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
// supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's
// width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data.
// Thumbnails can't be reused and can be only uploaded as a new file, so you can pass
// “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under
// <file_attach_name>. More information on Sending Files »
Thumbnail string `json:"thumbnail,omitempty"`
// Duration Optional. Duration of sent animation in seconds
Duration int `json:"duration,omitempty"`
// Width Optional. Animation width
Width int `json:"width,omitempty"`
// Height Optional. Animation height
Height int `json:"height,omitempty"`
// Caption Optional. Animation caption (may also be used when resending animation by file_id), 0-1024
// characters after entities parsing
Caption string `json:"caption,omitempty"`
// ParseMode Optional. Mode for parsing entities in the animation caption. See formatting options for more
// details.
ParseMode ParseMode `json:"parse_mode,omitempty"`
// CaptionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which
// can be specified instead of parse_mode
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// ShowCaptionAboveMedia Optional. Pass True if the caption must be shown above the message media
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// HasSpoiler Optional. Pass True if the animation needs to be covered with a spoiler animation
HasSpoiler bool `json:"has_spoiler,omitempty"`
// DisableNotification Optional. Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ProtectContent Optional. Protects the contents of the sent message from forwarding and saving
ProtectContent bool `json:"protect_content,omitempty"`
// AllowPaidBroadcast Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting
// limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's
// balance.
AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"`
// MessageEffectID Optional. Unique identifier of the message effect to be added to the message; for private
// chats only
MessageEffectID string `json:"message_effect_id,omitempty"`
// SuggestedPostParameters Optional. A JSON-serialized object containing the parameters of the suggested
// post to send; for direct messages chats only. If the message is sent as a reply to another suggested
// post, then that suggested post is automatically declined.
SuggestedPostParameters *SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
// ReplyParameters Optional. Description of the message to reply to
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
// ReplyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard,
// custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendAnimation sends an animation file (GIF or H.264/MPEG-4 AVC video without sound).
// Since: Bot API 4.0
// See https://core.telegram.org/bots/api#sendanimation
func (api *API) SendAnimation(params SendAnimation) (Message, error) {
req := NewRequestWithChatID[Message]("sendAnimation", params, params.ChatID)
return req.Do(api)
}
// SendAnimationWithContext is the context-aware variant of SendAnimation.
// Since: Bot API 4.0
// It executes the same request but uses ctx for cancellation and deadlines.
// See https://core.telegram.org/bots/api#sendanimation
func (api *API) SendAnimationWithContext(ctx context.Context, params SendAnimation) (Message, error) {
req := NewRequestWithChatID[Message]("sendAnimation", params, params.ChatID)
return req.DoWithContext(ctx, api)
}
// SendVoice holds parameters for the sendVoice method.
// Since: Bot API 1.2
// See https://core.telegram.org/bots/api#sendvoice
type SendVoice struct {
// BusinessConnectionID Optional. Unique identifier of the business connection on behalf of which the
// message will be sent
BusinessConnectionID string `json:"business_connection_id,omitempty"`
// ChatID Required. Unique identifier for the target chat or username of the target bot, supergroup or
// channel in the format @username
ChatID int64 `json:"chat_id"`
// MessageThreadID Optional. Unique identifier for the target message thread (topic) of a forum; for forum
// supergroups and private chats of bots with forum topic mode enabled only
MessageThreadID int `json:"message_thread_id,omitempty"`
// DirectMessagesTopicID Optional. Identifier of the direct messages topic to which the message will be
// sent; required if the message is sent to a direct messages chat
DirectMessagesTopicID int `json:"direct_messages_topic_id,omitempty"`
// ReceiverUserID identifies the user who can see the ephemeral message.
ReceiverUserID int64 `json:"receiver_user_id,omitempty"` // Since: Bot API 10.2
// CallbackQueryID identifies the callback query that triggered an ephemeral response.
CallbackQueryID string `json:"callback_query_id,omitempty"` // Since: Bot API 10.2
// Voice Required. Audio file to send. Pass a file_id as String to send a file that exists on the Telegram
// servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or
// upload a new one using multipart/form-data. More information on Sending Files »
Voice string `json:"voice"`
// Caption Optional. Voice message caption, 0-1024 characters after entities parsing
Caption string `json:"caption,omitempty"`
// ParseMode Optional. Mode for parsing entities in the voice message caption. See formatting options for
// more details.
ParseMode ParseMode `json:"parse_mode,omitempty"`
// CaptionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which
// can be specified instead of parse_mode
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Duration Optional. Duration of the voice message in seconds
Duration int `json:"duration,omitempty"`
// DisableNotification Optional. Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ProtectContent Optional. Protects the contents of the sent message from forwarding and saving
ProtectContent bool `json:"protect_content,omitempty"`
// AllowPaidBroadcast Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting
// limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's
// balance.
AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"`
// MessageEffectID Optional. Unique identifier of the message effect to be added to the message; for private
// chats only
MessageEffectID string `json:"message_effect_id,omitempty"`
// SuggestedPostParameters Optional. A JSON-serialized object containing the parameters of the suggested
// post to send; for direct messages chats only. If the message is sent as a reply to another suggested
// post, then that suggested post is automatically declined.
SuggestedPostParameters *SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
// ReplyParameters Optional. Description of the message to reply to
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
// ReplyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard,
// custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendVoice sends a voice note.
// Since: Bot API 1.2
// See https://core.telegram.org/bots/api#sendvoice
func (api *API) SendVoice(params SendVoice) (Message, error) {
req := NewRequestWithChatID[Message]("sendVoice", params, params.ChatID)
return req.Do(api)
}
// SendVoiceWithContext is the context-aware variant of SendVoice.
// Since: Bot API 1.2
// It executes the same request but uses ctx for cancellation and deadlines.
// See https://core.telegram.org/bots/api#sendvoice
func (api *API) SendVoiceWithContext(ctx context.Context, params SendVoice) (Message, error) {
req := NewRequestWithChatID[Message]("sendVoice", params, params.ChatID)
return req.DoWithContext(ctx, api)
}
// SendVideoNote holds parameters for the sendVideoNote method.
// Since: Bot API 3.0
// See https://core.telegram.org/bots/api#sendvideonote
type SendVideoNote struct {
// BusinessConnectionID Optional. Unique identifier of the business connection on behalf of which the
// message will be sent
BusinessConnectionID string `json:"business_connection_id,omitempty"`
// ChatID Required. Unique identifier for the target chat or username of the target bot, supergroup or
// channel in the format @username
ChatID int64 `json:"chat_id"`
// MessageThreadID Optional. Unique identifier for the target message thread (topic) of a forum; for forum
// supergroups and private chats of bots with forum topic mode enabled only
MessageThreadID int `json:"message_thread_id,omitempty"`
// DirectMessagesTopicID Optional. Identifier of the direct messages topic to which the message will be
// sent; required if the message is sent to a direct messages chat
DirectMessagesTopicID int `json:"direct_messages_topic_id,omitempty"`
// ReceiverUserID identifies the user who can see the ephemeral message.
ReceiverUserID int64 `json:"receiver_user_id,omitempty"` // Since: Bot API 10.2
// CallbackQueryID identifies the callback query that triggered an ephemeral response.
CallbackQueryID string `json:"callback_query_id,omitempty"` // Since: Bot API 10.2
// VideoNote Required. Video note to send. Pass a file_id as String to send a video note that exists on the
// Telegram servers (recommended) or upload a new video using multipart/form-data. More information on
// Sending Files ». Sending video notes by a URL is currently unsupported.
VideoNote string `json:"video_note"`
// Thumbnail Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
// supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's
// width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data.
// Thumbnails can't be reused and can be only uploaded as a new file, so you can pass
// “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under
// <file_attach_name>. More information on Sending Files »
Thumbnail string `json:"thumbnail,omitempty"`
// Duration Optional. Duration of sent video in seconds
Duration int `json:"duration,omitempty"`
// Length Optional. Video width and height, i.e. diameter of the video message
Length int `json:"length,omitempty"`
// DisableNotification Optional. Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ProtectContent Optional. Protects the contents of the sent message from forwarding and saving
ProtectContent bool `json:"protect_content,omitempty"`
// AllowPaidBroadcast Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting
// limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's
// balance.
AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"`
// MessageEffectID Optional. Unique identifier of the message effect to be added to the message; for private
// chats only
MessageEffectID string `json:"message_effect_id,omitempty"`
// SuggestedPostParameters Optional. A JSON-serialized object containing the parameters of the suggested
// post to send; for direct messages chats only. If the message is sent as a reply to another suggested
// post, then that suggested post is automatically declined.
SuggestedPostParameters *SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
// ReplyParameters Optional. Description of the message to reply to
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
// ReplyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard,
// custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendVideoNote sends a video note (rounded video message).
// Since: Bot API 3.0
// See https://core.telegram.org/bots/api#sendvideonote
func (api *API) SendVideoNote(params SendVideoNote) (Message, error) {
req := NewRequestWithChatID[Message]("sendVideoNote", params, params.ChatID)
return req.Do(api)
}
// SendVideoNoteWithContext is the context-aware variant of SendVideoNote.
// Since: Bot API 3.0
// It executes the same request but uses ctx for cancellation and deadlines.
// See https://core.telegram.org/bots/api#sendvideonote
func (api *API) SendVideoNoteWithContext(ctx context.Context, params SendVideoNote) (Message, error) {
req := NewRequestWithChatID[Message]("sendVideoNote", params, params.ChatID)
return req.DoWithContext(ctx, api)
}
// SendPaidMedia holds parameters for the sendPaidMedia method.
// Since: Bot API 7.6
// See https://core.telegram.org/bots/api#sendpaidmedia
type SendPaidMedia struct {
// BusinessConnectionID Optional. Unique identifier of the business connection on behalf of which the
// message will be sent
BusinessConnectionID string `json:"business_connection_id,omitempty"`
// ChatID Required. Unique identifier for the target chat or username of the target bot, supergroup or
// channel in the format @username. If the chat is a channel, all Telegram Star proceeds from this media
// will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.
ChatID int64 `json:"chat_id"`
// MessageThreadID Optional. Unique identifier for the target message thread (topic) of a forum; for forum
// supergroups and private chats of bots with forum topic mode enabled only
MessageThreadID int `json:"message_thread_id,omitempty"`
// DirectMessagesTopicID Optional. Identifier of the direct messages topic to which the message will be
// sent; required if the message is sent to a direct messages chat
DirectMessagesTopicID int `json:"direct_messages_topic_id,omitempty"`
// StarCount Required. The number of Telegram Stars that must be paid to buy access to the media; 1-25000
StarCount int `json:"star_count,omitempty"`
// Media Required. A JSON-serialized Array describing the media to be sent; up to 10 items
Media []InputPaidMedia `json:"media"`
// Payload Optional. Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user,
// use it for your internal processes.
Payload string `json:"payload,omitempty"`
// Caption Optional. Media caption, 0-1024 characters after entities parsing
Caption string `json:"caption,omitempty"`
// ParseMode Optional. Mode for parsing entities in the media caption. See formatting options for more
// details.
ParseMode ParseMode `json:"parse_mode,omitempty"`
// CaptionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which
// can be specified instead of parse_mode
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// ShowCaptionAboveMedia Optional. Pass True if the caption must be shown above the message media
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// DisableNotification Optional. Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ProtectContent Optional. Protects the contents of the sent message from forwarding and saving
ProtectContent bool `json:"protect_content,omitempty"`
// AllowPaidBroadcast Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting
// limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's
// balance.
AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"`
// SuggestedPostParameters Optional. A JSON-serialized object containing the parameters of the suggested
// post to send; for direct messages chats only. If the message is sent as a reply to another suggested
// post, then that suggested post is automatically declined.
SuggestedPostParameters *SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
// ReplyParameters Optional. Description of the message to reply to
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
// ReplyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard,
// custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendPaidMedia sends paid media.
// Since: Bot API 7.6
// See https://core.telegram.org/bots/api#sendpaidmedia
func (api *API) SendPaidMedia(params SendPaidMedia) (Message, error) {
req := NewRequestWithChatID[Message]("sendPaidMedia", params, params.ChatID)
return req.Do(api)
}
// SendPaidMediaWithContext is the context-aware variant of SendPaidMedia.
// Since: Bot API 7.6
// It executes the same request but uses ctx for cancellation and deadlines.
// See https://core.telegram.org/bots/api#sendpaidmedia
func (api *API) SendPaidMediaWithContext(ctx context.Context, params SendPaidMedia) (Message, error) {
req := NewRequestWithChatID[Message]("sendPaidMedia", params, params.ChatID)
return req.DoWithContext(ctx, api)
}
// SendMediaGroup holds parameters for the sendMediaGroup method.
// Since: Bot API 3.5
// See https://core.telegram.org/bots/api#sendmediagroup
type SendMediaGroup struct {
// BusinessConnectionID Optional. Unique identifier of the business connection on behalf of which the
// message will be sent
BusinessConnectionID string `json:"business_connection_id,omitempty"`
// ChatID Required. Unique identifier for the target chat or username of the target bot, supergroup or
// channel in the format @username
ChatID int64 `json:"chat_id"`
// MessageThreadID Optional. Unique identifier for the target message thread (topic) of a forum; for forum
// supergroups and private chats of bots with forum topic mode enabled only
MessageThreadID int `json:"message_thread_id,omitempty"`
// DirectMessagesTopicID Optional. Identifier of the direct messages topic to which the messages will be
// sent; required if the messages are sent to a direct messages chat
DirectMessagesTopicID int `json:"direct_messages_topic_id,omitempty"`
// Media Required. A JSON-serialized Array describing messages to be sent, must include 2-10 items
Media []InputMedia `json:"media"`
// DisableNotification Optional. Sends messages silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ProtectContent Optional. Protects the contents of the sent messages from forwarding and saving
ProtectContent bool `json:"protect_content,omitempty"`
// AllowPaidBroadcast Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting
// limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's
// balance.
AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"`
// MessageEffectID Optional. Unique identifier of the message effect to be added to the message; for private
// chats only
MessageEffectID string `json:"message_effect_id,omitempty"`
// ReplyParameters Optional. Description of the message to reply to
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
}
// SendMediaGroup sends a group of photos, videos, documents or audios as an album.
// Since: Bot API 3.5
// See https://core.telegram.org/bots/api#sendmediagroup
func (api *API) SendMediaGroup(params SendMediaGroup) ([]Message, error) {
req := NewRequestWithChatID[[]Message]("sendMediaGroup", params, params.ChatID)
return req.Do(api)
}
// SendMediaGroupWithContext is the context-aware variant of SendMediaGroup.
// Since: Bot API 3.5
// It executes the same request but uses ctx for cancellation and deadlines.
// See https://core.telegram.org/bots/api#sendmediagroup
func (api *API) SendMediaGroupWithContext(ctx context.Context, params SendMediaGroup) ([]Message, error) {
req := NewRequestWithChatID[[]Message]("sendMediaGroup", params, params.ChatID)
return req.DoWithContext(ctx, api)
}
// SendLivePhoto holds parameters for the sendLivePhoto method.
// Since: Bot API 10.0
// See https://core.telegram.org/bots/api#sendlivephoto
type SendLivePhoto struct {
// BusinessConnectionID Optional. Unique identifier of the business connection on behalf of which the
// message will be sent
BusinessConnectionID string `json:"business_connection_id,omitempty"`
// ChatID Required. Unique identifier for the target chat or username of the target channel (in the format
// @channelusername)
ChatID int64 `json:"chat_id"`
// MessageThreadID Optional. Unique identifier for the target message thread (topic) of a forum; for forum
// supergroups and private chats of bots with forum topic mode enabled only
MessageThreadID int `json:"message_thread_id,omitempty"`
// DirectMessagesTopicID Optional. Identifier of the direct messages topic to which the message will be
// sent; required if the message is sent to a direct messages chat
DirectMessagesTopicID int `json:"direct_messages_topic_id,omitempty"`
// ReceiverUserID identifies the user who can see the ephemeral message.
ReceiverUserID int64 `json:"receiver_user_id,omitempty"` // Since: Bot API 10.2
// CallbackQueryID identifies the callback query that triggered an ephemeral response.
CallbackQueryID string `json:"callback_query_id,omitempty"` // Since: Bot API 10.2
// LivePhoto Required. Live photo video to send. The video must be no longer than 10 seconds and must not
// exceed 10 MB in size. Pass a file_id as String to send a video that exists on the Telegram servers
// (recommended) or upload a new video using multipart/form-data. More information on Sending Files ».
// Sending live photos by a URL is currently unsupported.
LivePhoto string `json:"live_photo"`
// Photo contains or identifies the associated photo.
Photo string `json:"photo"`
// Caption Optional. Video caption (may also be used when resending videos by file_id), 0-1024 characters
// after entities parsing
Caption string `json:"caption,omitempty"`
// ParseMode Optional. Mode for parsing entities in the video caption. See formatting options for more
// details.
ParseMode ParseMode `json:"parse_mode,omitempty"`
// CaptionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which
// can be specified instead of parse_mode
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// ShowCaptionAboveMedia Optional. Pass True if the caption must be shown above the message media
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// HasSpoiler Optional. Pass True if the video needs to be covered with a spoiler animation
HasSpoiler bool `json:"has_spoiler,omitempty"`
// DisableNotification Optional. Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ProtectContent Optional. Protects the contents of the sent message from forwarding and saving
ProtectContent bool `json:"protect_content,omitempty"`
// AllowPaidBroadcast Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting
// limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's
// balance.
AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"`
// MessageEffectID Optional. Unique identifier of the message effect to be added to the message; for private
// chats only
MessageEffectID string `json:"message_effect_id,omitempty"`
// SuggestedPostParameters Optional. A JSON-serialized object containing the parameters of the suggested
// post to send; for direct messages chats only. If the message is sent as a reply to another suggested
// post, then that suggested post is automatically declined.
SuggestedPostParameters *SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
// ReplyParameters Optional. Description of the message to reply to
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
// ReplyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard,
// custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendLivePhoto sends a live photo.
// Since: Bot API 10.0
// See https://core.telegram.org/bots/api#sendlivephoto
func (api *API) SendLivePhoto(params SendLivePhoto) (Message, error) {
req := NewRequestWithChatID[Message]("sendLivePhoto", params, params.ChatID)
return req.Do(api)
}
// SendLivePhotoWithContext is the context-aware variant of SendLivePhoto.
// Since: Bot API 10.0
// It executes the same request but uses ctx for cancellation and deadlines.
// See https://core.telegram.org/bots/api#sendlivephoto
func (api *API) SendLivePhotoWithContext(ctx context.Context, params SendLivePhoto) (Message, error) {
req := NewRequestWithChatID[Message]("sendLivePhoto", params, params.ChatID)
return req.DoWithContext(ctx, api)
}