mirror of
https://github.com/lukaszraczylo/go-telegram.git
synced 2026-06-05 22:43:59 +00:00
f5250197b7
Co-authored-by: lukaszraczylo <2182556+lukaszraczylo@users.noreply.github.com>
5162 lines
315 KiB
Go
5162 lines
315 KiB
Go
// Code generated by cmd/genapi. DO NOT EDIT.
|
|
|
|
//go:build !ignore_autogenerated
|
|
|
|
package api
|
|
|
|
import (
|
|
"context"
|
|
"github.com/goccy/go-json"
|
|
"strconv"
|
|
|
|
"github.com/lukaszraczylo/go-telegram/client"
|
|
)
|
|
|
|
var _ = strconv.Itoa // keep import for multipart helpers
|
|
var _ = json.Marshal // keep import for complex multipart fields
|
|
|
|
// GetUpdatesParams is the parameter set for GetUpdates.
|
|
//
|
|
// Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects.
|
|
// Notes1. This method will not work if an outgoing webhook is set up.2. In order to avoid getting duplicate updates, recalculate offset after each server response.
|
|
type GetUpdatesParams struct {
|
|
// Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten.
|
|
Offset *int64 `json:"offset,omitempty"`
|
|
// Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.
|
|
Limit *int64 `json:"limit,omitempty"`
|
|
// Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.
|
|
Timeout *int64 `json:"timeout,omitempty"`
|
|
// A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.Please note that this parameter doesn't affect updates created before the call to getUpdates, so unwanted updates may be received for a short period of time.
|
|
AllowedUpdates []UpdateType `json:"allowed_updates,omitempty"`
|
|
}
|
|
|
|
// GetUpdates calls the getUpdates Telegram Bot API method.
|
|
//
|
|
// Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects.
|
|
// Notes1. This method will not work if an outgoing webhook is set up.2. In order to avoid getting duplicate updates, recalculate offset after each server response.
|
|
func GetUpdates(ctx context.Context, b *client.Bot, p *GetUpdatesParams) ([]Update, error) {
|
|
return client.Call[*GetUpdatesParams, []Update](ctx, b, "getUpdates", p)
|
|
}
|
|
|
|
// SetWebhookParams is the parameter set for SetWebhook.
|
|
//
|
|
// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success.
|
|
// If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
|
|
// Notes1. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up.2. To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. Please upload as InputFile, sending a String will not work.3. Ports currently supported for webhooks: 443, 80, 88, 8443.
|
|
// If you're having any trouble setting up webhooks, please check out this amazing guide to webhooks.
|
|
type SetWebhookParams struct {
|
|
// HTTPS URL to send updates to. Use an empty string to remove webhook integration.
|
|
URL string `json:"url"`
|
|
// Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details.
|
|
Certificate *InputFile `json:"certificate,omitempty"`
|
|
// The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS
|
|
IPAddress string `json:"ip_address,omitempty"`
|
|
// The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.
|
|
MaxConnections *int64 `json:"max_connections,omitempty"`
|
|
// A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time.
|
|
AllowedUpdates []UpdateType `json:"allowed_updates,omitempty"`
|
|
// Pass True to drop all pending updates
|
|
DropPendingUpdates *bool `json:"drop_pending_updates,omitempty"`
|
|
// A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.
|
|
SecretToken string `json:"secret_token,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SetWebhookParams) HasFile() bool {
|
|
if p.Certificate != nil && p.Certificate.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SetWebhookParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
out["url"] = p.URL
|
|
if p.IPAddress != "" {
|
|
out["ip_address"] = p.IPAddress
|
|
}
|
|
if p.MaxConnections != nil {
|
|
out["max_connections"] = strconv.FormatInt(*p.MaxConnections, 10)
|
|
}
|
|
if p.AllowedUpdates != nil {
|
|
if b, _ := json.Marshal(p.AllowedUpdates); len(b) > 0 {
|
|
out["allowed_updates"] = string(b)
|
|
}
|
|
}
|
|
if p.DropPendingUpdates != nil {
|
|
out["drop_pending_updates"] = strconv.FormatBool(*p.DropPendingUpdates)
|
|
}
|
|
if p.SecretToken != "" {
|
|
out["secret_token"] = p.SecretToken
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SetWebhookParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.Certificate != nil && p.Certificate.IsLocalUpload() {
|
|
name := p.Certificate.Filename
|
|
if name == "" {
|
|
name = "certificate"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "certificate", Filename: name, Reader: p.Certificate.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SetWebhook calls the setWebhook Telegram Bot API method.
|
|
//
|
|
// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success.
|
|
// If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
|
|
// Notes1. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up.2. To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. Please upload as InputFile, sending a String will not work.3. Ports currently supported for webhooks: 443, 80, 88, 8443.
|
|
// If you're having any trouble setting up webhooks, please check out this amazing guide to webhooks.
|
|
func SetWebhook(ctx context.Context, b *client.Bot, p *SetWebhookParams) (bool, error) {
|
|
return client.Call[*SetWebhookParams, bool](ctx, b, "setWebhook", p)
|
|
}
|
|
|
|
// DeleteWebhookParams is the parameter set for DeleteWebhook.
|
|
//
|
|
// Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success.
|
|
type DeleteWebhookParams struct {
|
|
// Pass True to drop all pending updates
|
|
DropPendingUpdates *bool `json:"drop_pending_updates,omitempty"`
|
|
}
|
|
|
|
// DeleteWebhook calls the deleteWebhook Telegram Bot API method.
|
|
//
|
|
// Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success.
|
|
func DeleteWebhook(ctx context.Context, b *client.Bot, p *DeleteWebhookParams) (bool, error) {
|
|
return client.Call[*DeleteWebhookParams, bool](ctx, b, "deleteWebhook", p)
|
|
}
|
|
|
|
// GetWebhookInfoParams is the parameter set for GetWebhookInfo.
|
|
//
|
|
// Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.
|
|
type GetWebhookInfoParams struct {
|
|
}
|
|
|
|
// GetWebhookInfo calls the getWebhookInfo Telegram Bot API method.
|
|
//
|
|
// Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.
|
|
func GetWebhookInfo(ctx context.Context, b *client.Bot, p *GetWebhookInfoParams) (*WebhookInfo, error) {
|
|
return client.Call[*GetWebhookInfoParams, *WebhookInfo](ctx, b, "getWebhookInfo", p)
|
|
}
|
|
|
|
// GetMeParams is the parameter set for GetMe.
|
|
//
|
|
// A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.
|
|
type GetMeParams struct {
|
|
}
|
|
|
|
// GetMe calls the getMe Telegram Bot API method.
|
|
//
|
|
// A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.
|
|
func GetMe(ctx context.Context, b *client.Bot, p *GetMeParams) (*User, error) {
|
|
return client.Call[*GetMeParams, *User](ctx, b, "getMe", p)
|
|
}
|
|
|
|
// LogOutParams is the parameter set for LogOut.
|
|
//
|
|
// Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters.
|
|
type LogOutParams struct {
|
|
}
|
|
|
|
// LogOut calls the logOut Telegram Bot API method.
|
|
//
|
|
// Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters.
|
|
func LogOut(ctx context.Context, b *client.Bot, p *LogOutParams) (bool, error) {
|
|
return client.Call[*LogOutParams, bool](ctx, b, "logOut", p)
|
|
}
|
|
|
|
// CloseParams is the parameter set for Close.
|
|
//
|
|
// Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters.
|
|
type CloseParams struct {
|
|
}
|
|
|
|
// Close calls the close Telegram Bot API method.
|
|
//
|
|
// Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters.
|
|
func Close(ctx context.Context, b *client.Bot, p *CloseParams) (bool, error) {
|
|
return client.Call[*CloseParams, bool](ctx, b, "close", p)
|
|
}
|
|
|
|
// SendMessageParams is the parameter set for SendMessage.
|
|
//
|
|
// Use this method to send text messages. On success, the sent Message is returned.
|
|
type SendMessageParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// Text of the message to be sent, 1-4096 characters after entities parsing
|
|
Text string `json:"text"`
|
|
// Mode for parsing entities in the message text. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode
|
|
Entities []MessageEntity `json:"entities,omitempty"`
|
|
// Link preview generation options for the message
|
|
LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// SendMessage calls the sendMessage Telegram Bot API method.
|
|
//
|
|
// Use this method to send text messages. On success, the sent Message is returned.
|
|
func SendMessage(ctx context.Context, b *client.Bot, p *SendMessageParams) (*Message, error) {
|
|
return client.Call[*SendMessageParams, *Message](ctx, b, "sendMessage", p)
|
|
}
|
|
|
|
// ForwardMessageParams is the parameter set for ForwardMessage.
|
|
//
|
|
// Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned.
|
|
type ForwardMessageParams struct {
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// Identifier of the direct messages topic to which the message will be forwarded; required if the message is forwarded to a direct messages chat
|
|
DirectMessagesTopicID *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// Unique identifier for the chat where the original message was sent (or username of the target bot, supergroup or channel in the format @username)
|
|
FromChatID ChatID `json:"from_chat_id"`
|
|
// New start timestamp for the forwarded video in the message
|
|
VideoStartTimestamp *int64 `json:"video_start_timestamp,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the forwarded message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// Unique identifier of the message effect to be added to the message; only available when forwarding to private chats
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only
|
|
SuggestedPostParameters *SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
|
|
// Message identifier in the chat specified in from_chat_id
|
|
MessageID int64 `json:"message_id"`
|
|
}
|
|
|
|
// ForwardMessage calls the forwardMessage Telegram Bot API method.
|
|
//
|
|
// Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned.
|
|
func ForwardMessage(ctx context.Context, b *client.Bot, p *ForwardMessageParams) (*Message, error) {
|
|
return client.Call[*ForwardMessageParams, *Message](ctx, b, "forwardMessage", p)
|
|
}
|
|
|
|
// ForwardMessagesParams is the parameter set for ForwardMessages.
|
|
//
|
|
// Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned.
|
|
type ForwardMessagesParams struct {
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// Identifier of the direct messages topic to which the messages will be forwarded; required if the messages are forwarded to a direct messages chat
|
|
DirectMessagesTopicID *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// Unique identifier for the chat where the original messages were sent (or username of the target bot, supergroup or channel in the format @username)
|
|
FromChatID ChatID `json:"from_chat_id"`
|
|
// A JSON-serialized list of 1-100 identifiers of messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order.
|
|
MessageIds []int64 `json:"message_ids"`
|
|
// Sends the messages silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the forwarded messages from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
}
|
|
|
|
// ForwardMessages calls the forwardMessages Telegram Bot API method.
|
|
//
|
|
// Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned.
|
|
func ForwardMessages(ctx context.Context, b *client.Bot, p *ForwardMessagesParams) ([]MessageId, error) {
|
|
return client.Call[*ForwardMessagesParams, []MessageId](ctx, b, "forwardMessages", p)
|
|
}
|
|
|
|
// CopyMessageParams is the parameter set for CopyMessage.
|
|
//
|
|
// Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success.
|
|
type CopyMessageParams struct {
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// Unique identifier for the chat where the original message was sent (or username of the target bot, supergroup or channel in the format @username)
|
|
FromChatID ChatID `json:"from_chat_id"`
|
|
// Message identifier in the chat specified in from_chat_id
|
|
MessageID int64 `json:"message_id"`
|
|
// New start timestamp for the copied video in the message
|
|
VideoStartTimestamp *int64 `json:"video_start_timestamp,omitempty"`
|
|
// New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept.
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the new caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of parse_mode
|
|
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
|
// Pass True, if the caption must be shown above the message media. Ignored if a new caption isn't specified.
|
|
ShowCaptionAboveMedia *bool `json:"show_caption_above_media,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; only available when copying to private chats
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// CopyMessage calls the copyMessage Telegram Bot API method.
|
|
//
|
|
// Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success.
|
|
func CopyMessage(ctx context.Context, b *client.Bot, p *CopyMessageParams) (*MessageId, error) {
|
|
return client.Call[*CopyMessageParams, *MessageId](ctx, b, "copyMessage", p)
|
|
}
|
|
|
|
// CopyMessagesParams is the parameter set for CopyMessages.
|
|
//
|
|
// Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned.
|
|
type CopyMessagesParams struct {
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// Unique identifier for the chat where the original messages were sent (or username of the target bot, supergroup or channel in the format @username)
|
|
FromChatID ChatID `json:"from_chat_id"`
|
|
// A JSON-serialized list of 1-100 identifiers of messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.
|
|
MessageIds []int64 `json:"message_ids"`
|
|
// Sends the messages silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent messages from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// Pass True to copy the messages without their captions
|
|
RemoveCaption *bool `json:"remove_caption,omitempty"`
|
|
}
|
|
|
|
// CopyMessages calls the copyMessages Telegram Bot API method.
|
|
//
|
|
// Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned.
|
|
func CopyMessages(ctx context.Context, b *client.Bot, p *CopyMessagesParams) ([]MessageId, error) {
|
|
return client.Call[*CopyMessagesParams, []MessageId](ctx, b, "copyMessages", p)
|
|
}
|
|
|
|
// SendPhotoParams is the parameter set for SendPhoto.
|
|
//
|
|
// Use this method to send photos. On success, the sent Message is returned.
|
|
type SendPhotoParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// 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 *InputFile `json:"photo"`
|
|
// Photo caption (may also be used when resending photos by file_id), 0-1024 characters after entities parsing
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the photo caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// 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"`
|
|
// Pass True, if the caption must be shown above the message media
|
|
ShowCaptionAboveMedia *bool `json:"show_caption_above_media,omitempty"`
|
|
// Pass True if the photo needs to be covered with a spoiler animation
|
|
HasSpoiler *bool `json:"has_spoiler,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SendPhotoParams) HasFile() bool {
|
|
if p.Photo != nil && p.Photo.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SendPhotoParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
out["chat_id"] = p.ChatID.String()
|
|
if p.MessageThreadID != nil {
|
|
out["message_thread_id"] = strconv.FormatInt(*p.MessageThreadID, 10)
|
|
}
|
|
if p.DirectMessagesTopicID != nil {
|
|
out["direct_messages_topic_id"] = strconv.FormatInt(*p.DirectMessagesTopicID, 10)
|
|
}
|
|
if p.Caption != "" {
|
|
out["caption"] = p.Caption
|
|
}
|
|
if p.ParseMode != "" {
|
|
out["parse_mode"] = string(p.ParseMode)
|
|
}
|
|
if p.CaptionEntities != nil {
|
|
if b, _ := json.Marshal(p.CaptionEntities); len(b) > 0 {
|
|
out["caption_entities"] = string(b)
|
|
}
|
|
}
|
|
if p.ShowCaptionAboveMedia != nil {
|
|
out["show_caption_above_media"] = strconv.FormatBool(*p.ShowCaptionAboveMedia)
|
|
}
|
|
if p.HasSpoiler != nil {
|
|
out["has_spoiler"] = strconv.FormatBool(*p.HasSpoiler)
|
|
}
|
|
if p.DisableNotification != nil {
|
|
out["disable_notification"] = strconv.FormatBool(*p.DisableNotification)
|
|
}
|
|
if p.ProtectContent != nil {
|
|
out["protect_content"] = strconv.FormatBool(*p.ProtectContent)
|
|
}
|
|
if p.AllowPaidBroadcast != nil {
|
|
out["allow_paid_broadcast"] = strconv.FormatBool(*p.AllowPaidBroadcast)
|
|
}
|
|
if p.MessageEffectID != "" {
|
|
out["message_effect_id"] = p.MessageEffectID
|
|
}
|
|
if p.SuggestedPostParameters != nil {
|
|
if b, _ := json.Marshal(p.SuggestedPostParameters); len(b) > 0 {
|
|
out["suggested_post_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyParameters != nil {
|
|
if b, _ := json.Marshal(p.ReplyParameters); len(b) > 0 {
|
|
out["reply_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyMarkup != nil {
|
|
if b, _ := json.Marshal(p.ReplyMarkup); len(b) > 0 && string(b) != "null" {
|
|
out["reply_markup"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SendPhotoParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.Photo != nil && p.Photo.IsLocalUpload() {
|
|
name := p.Photo.Filename
|
|
if name == "" {
|
|
name = "photo"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "photo", Filename: name, Reader: p.Photo.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SendPhoto calls the sendPhoto Telegram Bot API method.
|
|
//
|
|
// Use this method to send photos. On success, the sent Message is returned.
|
|
func SendPhoto(ctx context.Context, b *client.Bot, p *SendPhotoParams) (*Message, error) {
|
|
return client.Call[*SendPhotoParams, *Message](ctx, b, "sendPhoto", p)
|
|
}
|
|
|
|
// SendLivePhotoParams is the parameter set for SendLivePhoto.
|
|
//
|
|
// Use this method to send live photos. On success, the sent Message is returned.
|
|
type SendLivePhotoParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// 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 *InputFile `json:"live_photo"`
|
|
// The static photo to send. Pass a file_id as String to send a photo 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.
|
|
Photo *InputFile `json:"photo"`
|
|
// Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the video caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// 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"`
|
|
// Pass True, if the caption must be shown above the message media
|
|
ShowCaptionAboveMedia *bool `json:"show_caption_above_media,omitempty"`
|
|
// Pass True if the video needs to be covered with a spoiler animation
|
|
HasSpoiler *bool `json:"has_spoiler,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SendLivePhotoParams) HasFile() bool {
|
|
if p.LivePhoto != nil && p.LivePhoto.IsLocalUpload() {
|
|
return true
|
|
}
|
|
if p.Photo != nil && p.Photo.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SendLivePhotoParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
out["chat_id"] = p.ChatID.String()
|
|
if p.MessageThreadID != nil {
|
|
out["message_thread_id"] = strconv.FormatInt(*p.MessageThreadID, 10)
|
|
}
|
|
if p.DirectMessagesTopicID != nil {
|
|
out["direct_messages_topic_id"] = strconv.FormatInt(*p.DirectMessagesTopicID, 10)
|
|
}
|
|
if p.Caption != "" {
|
|
out["caption"] = p.Caption
|
|
}
|
|
if p.ParseMode != "" {
|
|
out["parse_mode"] = string(p.ParseMode)
|
|
}
|
|
if p.CaptionEntities != nil {
|
|
if b, _ := json.Marshal(p.CaptionEntities); len(b) > 0 {
|
|
out["caption_entities"] = string(b)
|
|
}
|
|
}
|
|
if p.ShowCaptionAboveMedia != nil {
|
|
out["show_caption_above_media"] = strconv.FormatBool(*p.ShowCaptionAboveMedia)
|
|
}
|
|
if p.HasSpoiler != nil {
|
|
out["has_spoiler"] = strconv.FormatBool(*p.HasSpoiler)
|
|
}
|
|
if p.DisableNotification != nil {
|
|
out["disable_notification"] = strconv.FormatBool(*p.DisableNotification)
|
|
}
|
|
if p.ProtectContent != nil {
|
|
out["protect_content"] = strconv.FormatBool(*p.ProtectContent)
|
|
}
|
|
if p.AllowPaidBroadcast != nil {
|
|
out["allow_paid_broadcast"] = strconv.FormatBool(*p.AllowPaidBroadcast)
|
|
}
|
|
if p.MessageEffectID != "" {
|
|
out["message_effect_id"] = p.MessageEffectID
|
|
}
|
|
if p.SuggestedPostParameters != nil {
|
|
if b, _ := json.Marshal(p.SuggestedPostParameters); len(b) > 0 {
|
|
out["suggested_post_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyParameters != nil {
|
|
if b, _ := json.Marshal(p.ReplyParameters); len(b) > 0 {
|
|
out["reply_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyMarkup != nil {
|
|
if b, _ := json.Marshal(p.ReplyMarkup); len(b) > 0 && string(b) != "null" {
|
|
out["reply_markup"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SendLivePhotoParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.LivePhoto != nil && p.LivePhoto.IsLocalUpload() {
|
|
name := p.LivePhoto.Filename
|
|
if name == "" {
|
|
name = "live_photo"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "live_photo", Filename: name, Reader: p.LivePhoto.Reader})
|
|
}
|
|
if p.Photo != nil && p.Photo.IsLocalUpload() {
|
|
name := p.Photo.Filename
|
|
if name == "" {
|
|
name = "photo"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "photo", Filename: name, Reader: p.Photo.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SendLivePhoto calls the sendLivePhoto Telegram Bot API method.
|
|
//
|
|
// Use this method to send live photos. On success, the sent Message is returned.
|
|
func SendLivePhoto(ctx context.Context, b *client.Bot, p *SendLivePhotoParams) (*Message, error) {
|
|
return client.Call[*SendLivePhotoParams, *Message](ctx, b, "sendLivePhoto", p)
|
|
}
|
|
|
|
// SendAudioParams is the parameter set for SendAudio.
|
|
//
|
|
// Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
|
|
// For sending voice messages, use the sendVoice method instead.
|
|
type SendAudioParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// 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 *InputFile `json:"audio"`
|
|
// Audio caption, 0-1024 characters after entities parsing
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the audio caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// 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 of the audio in seconds
|
|
Duration *int64 `json:"duration,omitempty"`
|
|
// Performer
|
|
Performer string `json:"performer,omitempty"`
|
|
// Track name
|
|
Title string `json:"title,omitempty"`
|
|
// 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 *InputFile `json:"thumbnail,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SendAudioParams) HasFile() bool {
|
|
if p.Audio != nil && p.Audio.IsLocalUpload() {
|
|
return true
|
|
}
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SendAudioParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
out["chat_id"] = p.ChatID.String()
|
|
if p.MessageThreadID != nil {
|
|
out["message_thread_id"] = strconv.FormatInt(*p.MessageThreadID, 10)
|
|
}
|
|
if p.DirectMessagesTopicID != nil {
|
|
out["direct_messages_topic_id"] = strconv.FormatInt(*p.DirectMessagesTopicID, 10)
|
|
}
|
|
if p.Caption != "" {
|
|
out["caption"] = p.Caption
|
|
}
|
|
if p.ParseMode != "" {
|
|
out["parse_mode"] = string(p.ParseMode)
|
|
}
|
|
if p.CaptionEntities != nil {
|
|
if b, _ := json.Marshal(p.CaptionEntities); len(b) > 0 {
|
|
out["caption_entities"] = string(b)
|
|
}
|
|
}
|
|
if p.Duration != nil {
|
|
out["duration"] = strconv.FormatInt(*p.Duration, 10)
|
|
}
|
|
if p.Performer != "" {
|
|
out["performer"] = p.Performer
|
|
}
|
|
if p.Title != "" {
|
|
out["title"] = p.Title
|
|
}
|
|
if p.DisableNotification != nil {
|
|
out["disable_notification"] = strconv.FormatBool(*p.DisableNotification)
|
|
}
|
|
if p.ProtectContent != nil {
|
|
out["protect_content"] = strconv.FormatBool(*p.ProtectContent)
|
|
}
|
|
if p.AllowPaidBroadcast != nil {
|
|
out["allow_paid_broadcast"] = strconv.FormatBool(*p.AllowPaidBroadcast)
|
|
}
|
|
if p.MessageEffectID != "" {
|
|
out["message_effect_id"] = p.MessageEffectID
|
|
}
|
|
if p.SuggestedPostParameters != nil {
|
|
if b, _ := json.Marshal(p.SuggestedPostParameters); len(b) > 0 {
|
|
out["suggested_post_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyParameters != nil {
|
|
if b, _ := json.Marshal(p.ReplyParameters); len(b) > 0 {
|
|
out["reply_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyMarkup != nil {
|
|
if b, _ := json.Marshal(p.ReplyMarkup); len(b) > 0 && string(b) != "null" {
|
|
out["reply_markup"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SendAudioParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.Audio != nil && p.Audio.IsLocalUpload() {
|
|
name := p.Audio.Filename
|
|
if name == "" {
|
|
name = "audio"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "audio", Filename: name, Reader: p.Audio.Reader})
|
|
}
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
name := p.Thumbnail.Filename
|
|
if name == "" {
|
|
name = "thumbnail"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "thumbnail", Filename: name, Reader: p.Thumbnail.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SendAudio calls the sendAudio Telegram Bot API method.
|
|
//
|
|
// Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
|
|
// For sending voice messages, use the sendVoice method instead.
|
|
func SendAudio(ctx context.Context, b *client.Bot, p *SendAudioParams) (*Message, error) {
|
|
return client.Call[*SendAudioParams, *Message](ctx, b, "sendAudio", p)
|
|
}
|
|
|
|
// SendDocumentParams is the parameter set for SendDocument.
|
|
//
|
|
// Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
|
|
type SendDocumentParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// 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 *InputFile `json:"document"`
|
|
// 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 *InputFile `json:"thumbnail,omitempty"`
|
|
// Document caption (may also be used when resending documents by file_id), 0-1024 characters after entities parsing
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the document caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// 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"`
|
|
// Disables automatic server-side content type detection for files uploaded using multipart/form-data
|
|
DisableContentTypeDetection *bool `json:"disable_content_type_detection,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SendDocumentParams) HasFile() bool {
|
|
if p.Document != nil && p.Document.IsLocalUpload() {
|
|
return true
|
|
}
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SendDocumentParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
out["chat_id"] = p.ChatID.String()
|
|
if p.MessageThreadID != nil {
|
|
out["message_thread_id"] = strconv.FormatInt(*p.MessageThreadID, 10)
|
|
}
|
|
if p.DirectMessagesTopicID != nil {
|
|
out["direct_messages_topic_id"] = strconv.FormatInt(*p.DirectMessagesTopicID, 10)
|
|
}
|
|
if p.Caption != "" {
|
|
out["caption"] = p.Caption
|
|
}
|
|
if p.ParseMode != "" {
|
|
out["parse_mode"] = string(p.ParseMode)
|
|
}
|
|
if p.CaptionEntities != nil {
|
|
if b, _ := json.Marshal(p.CaptionEntities); len(b) > 0 {
|
|
out["caption_entities"] = string(b)
|
|
}
|
|
}
|
|
if p.DisableContentTypeDetection != nil {
|
|
out["disable_content_type_detection"] = strconv.FormatBool(*p.DisableContentTypeDetection)
|
|
}
|
|
if p.DisableNotification != nil {
|
|
out["disable_notification"] = strconv.FormatBool(*p.DisableNotification)
|
|
}
|
|
if p.ProtectContent != nil {
|
|
out["protect_content"] = strconv.FormatBool(*p.ProtectContent)
|
|
}
|
|
if p.AllowPaidBroadcast != nil {
|
|
out["allow_paid_broadcast"] = strconv.FormatBool(*p.AllowPaidBroadcast)
|
|
}
|
|
if p.MessageEffectID != "" {
|
|
out["message_effect_id"] = p.MessageEffectID
|
|
}
|
|
if p.SuggestedPostParameters != nil {
|
|
if b, _ := json.Marshal(p.SuggestedPostParameters); len(b) > 0 {
|
|
out["suggested_post_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyParameters != nil {
|
|
if b, _ := json.Marshal(p.ReplyParameters); len(b) > 0 {
|
|
out["reply_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyMarkup != nil {
|
|
if b, _ := json.Marshal(p.ReplyMarkup); len(b) > 0 && string(b) != "null" {
|
|
out["reply_markup"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SendDocumentParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.Document != nil && p.Document.IsLocalUpload() {
|
|
name := p.Document.Filename
|
|
if name == "" {
|
|
name = "document"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "document", Filename: name, Reader: p.Document.Reader})
|
|
}
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
name := p.Thumbnail.Filename
|
|
if name == "" {
|
|
name = "thumbnail"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "thumbnail", Filename: name, Reader: p.Thumbnail.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SendDocument calls the sendDocument Telegram Bot API method.
|
|
//
|
|
// Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
|
|
func SendDocument(ctx context.Context, b *client.Bot, p *SendDocumentParams) (*Message, error) {
|
|
return client.Call[*SendDocumentParams, *Message](ctx, b, "sendDocument", p)
|
|
}
|
|
|
|
// SendVideoParams is the parameter set for SendVideo.
|
|
//
|
|
// Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
|
|
type SendVideoParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// 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 *InputFile `json:"video"`
|
|
// Duration of sent video in seconds
|
|
Duration *int64 `json:"duration,omitempty"`
|
|
// Video width
|
|
Width *int64 `json:"width,omitempty"`
|
|
// Video height
|
|
Height *int64 `json:"height,omitempty"`
|
|
// 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 *InputFile `json:"thumbnail,omitempty"`
|
|
// 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 *InputFile `json:"cover,omitempty"`
|
|
// Start timestamp for the video in the message
|
|
StartTimestamp *int64 `json:"start_timestamp,omitempty"`
|
|
// Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the video caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// 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"`
|
|
// Pass True, if the caption must be shown above the message media
|
|
ShowCaptionAboveMedia *bool `json:"show_caption_above_media,omitempty"`
|
|
// Pass True if the video needs to be covered with a spoiler animation
|
|
HasSpoiler *bool `json:"has_spoiler,omitempty"`
|
|
// Pass True if the uploaded video is suitable for streaming
|
|
SupportsStreaming *bool `json:"supports_streaming,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SendVideoParams) HasFile() bool {
|
|
if p.Video != nil && p.Video.IsLocalUpload() {
|
|
return true
|
|
}
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
return true
|
|
}
|
|
if p.Cover != nil && p.Cover.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SendVideoParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
out["chat_id"] = p.ChatID.String()
|
|
if p.MessageThreadID != nil {
|
|
out["message_thread_id"] = strconv.FormatInt(*p.MessageThreadID, 10)
|
|
}
|
|
if p.DirectMessagesTopicID != nil {
|
|
out["direct_messages_topic_id"] = strconv.FormatInt(*p.DirectMessagesTopicID, 10)
|
|
}
|
|
if p.Duration != nil {
|
|
out["duration"] = strconv.FormatInt(*p.Duration, 10)
|
|
}
|
|
if p.Width != nil {
|
|
out["width"] = strconv.FormatInt(*p.Width, 10)
|
|
}
|
|
if p.Height != nil {
|
|
out["height"] = strconv.FormatInt(*p.Height, 10)
|
|
}
|
|
if p.StartTimestamp != nil {
|
|
out["start_timestamp"] = strconv.FormatInt(*p.StartTimestamp, 10)
|
|
}
|
|
if p.Caption != "" {
|
|
out["caption"] = p.Caption
|
|
}
|
|
if p.ParseMode != "" {
|
|
out["parse_mode"] = string(p.ParseMode)
|
|
}
|
|
if p.CaptionEntities != nil {
|
|
if b, _ := json.Marshal(p.CaptionEntities); len(b) > 0 {
|
|
out["caption_entities"] = string(b)
|
|
}
|
|
}
|
|
if p.ShowCaptionAboveMedia != nil {
|
|
out["show_caption_above_media"] = strconv.FormatBool(*p.ShowCaptionAboveMedia)
|
|
}
|
|
if p.HasSpoiler != nil {
|
|
out["has_spoiler"] = strconv.FormatBool(*p.HasSpoiler)
|
|
}
|
|
if p.SupportsStreaming != nil {
|
|
out["supports_streaming"] = strconv.FormatBool(*p.SupportsStreaming)
|
|
}
|
|
if p.DisableNotification != nil {
|
|
out["disable_notification"] = strconv.FormatBool(*p.DisableNotification)
|
|
}
|
|
if p.ProtectContent != nil {
|
|
out["protect_content"] = strconv.FormatBool(*p.ProtectContent)
|
|
}
|
|
if p.AllowPaidBroadcast != nil {
|
|
out["allow_paid_broadcast"] = strconv.FormatBool(*p.AllowPaidBroadcast)
|
|
}
|
|
if p.MessageEffectID != "" {
|
|
out["message_effect_id"] = p.MessageEffectID
|
|
}
|
|
if p.SuggestedPostParameters != nil {
|
|
if b, _ := json.Marshal(p.SuggestedPostParameters); len(b) > 0 {
|
|
out["suggested_post_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyParameters != nil {
|
|
if b, _ := json.Marshal(p.ReplyParameters); len(b) > 0 {
|
|
out["reply_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyMarkup != nil {
|
|
if b, _ := json.Marshal(p.ReplyMarkup); len(b) > 0 && string(b) != "null" {
|
|
out["reply_markup"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SendVideoParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.Video != nil && p.Video.IsLocalUpload() {
|
|
name := p.Video.Filename
|
|
if name == "" {
|
|
name = "video"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "video", Filename: name, Reader: p.Video.Reader})
|
|
}
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
name := p.Thumbnail.Filename
|
|
if name == "" {
|
|
name = "thumbnail"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "thumbnail", Filename: name, Reader: p.Thumbnail.Reader})
|
|
}
|
|
if p.Cover != nil && p.Cover.IsLocalUpload() {
|
|
name := p.Cover.Filename
|
|
if name == "" {
|
|
name = "cover"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "cover", Filename: name, Reader: p.Cover.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SendVideo calls the sendVideo Telegram Bot API method.
|
|
//
|
|
// Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
|
|
func SendVideo(ctx context.Context, b *client.Bot, p *SendVideoParams) (*Message, error) {
|
|
return client.Call[*SendVideoParams, *Message](ctx, b, "sendVideo", p)
|
|
}
|
|
|
|
// SendAnimationParams is the parameter set for SendAnimation.
|
|
//
|
|
// Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
|
|
type SendAnimationParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// 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 *InputFile `json:"animation"`
|
|
// Duration of sent animation in seconds
|
|
Duration *int64 `json:"duration,omitempty"`
|
|
// Animation width
|
|
Width *int64 `json:"width,omitempty"`
|
|
// Animation height
|
|
Height *int64 `json:"height,omitempty"`
|
|
// 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 *InputFile `json:"thumbnail,omitempty"`
|
|
// Animation caption (may also be used when resending animation by file_id), 0-1024 characters after entities parsing
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the animation caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// 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"`
|
|
// Pass True, if the caption must be shown above the message media
|
|
ShowCaptionAboveMedia *bool `json:"show_caption_above_media,omitempty"`
|
|
// Pass True if the animation needs to be covered with a spoiler animation
|
|
HasSpoiler *bool `json:"has_spoiler,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SendAnimationParams) HasFile() bool {
|
|
if p.Animation != nil && p.Animation.IsLocalUpload() {
|
|
return true
|
|
}
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SendAnimationParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
out["chat_id"] = p.ChatID.String()
|
|
if p.MessageThreadID != nil {
|
|
out["message_thread_id"] = strconv.FormatInt(*p.MessageThreadID, 10)
|
|
}
|
|
if p.DirectMessagesTopicID != nil {
|
|
out["direct_messages_topic_id"] = strconv.FormatInt(*p.DirectMessagesTopicID, 10)
|
|
}
|
|
if p.Duration != nil {
|
|
out["duration"] = strconv.FormatInt(*p.Duration, 10)
|
|
}
|
|
if p.Width != nil {
|
|
out["width"] = strconv.FormatInt(*p.Width, 10)
|
|
}
|
|
if p.Height != nil {
|
|
out["height"] = strconv.FormatInt(*p.Height, 10)
|
|
}
|
|
if p.Caption != "" {
|
|
out["caption"] = p.Caption
|
|
}
|
|
if p.ParseMode != "" {
|
|
out["parse_mode"] = string(p.ParseMode)
|
|
}
|
|
if p.CaptionEntities != nil {
|
|
if b, _ := json.Marshal(p.CaptionEntities); len(b) > 0 {
|
|
out["caption_entities"] = string(b)
|
|
}
|
|
}
|
|
if p.ShowCaptionAboveMedia != nil {
|
|
out["show_caption_above_media"] = strconv.FormatBool(*p.ShowCaptionAboveMedia)
|
|
}
|
|
if p.HasSpoiler != nil {
|
|
out["has_spoiler"] = strconv.FormatBool(*p.HasSpoiler)
|
|
}
|
|
if p.DisableNotification != nil {
|
|
out["disable_notification"] = strconv.FormatBool(*p.DisableNotification)
|
|
}
|
|
if p.ProtectContent != nil {
|
|
out["protect_content"] = strconv.FormatBool(*p.ProtectContent)
|
|
}
|
|
if p.AllowPaidBroadcast != nil {
|
|
out["allow_paid_broadcast"] = strconv.FormatBool(*p.AllowPaidBroadcast)
|
|
}
|
|
if p.MessageEffectID != "" {
|
|
out["message_effect_id"] = p.MessageEffectID
|
|
}
|
|
if p.SuggestedPostParameters != nil {
|
|
if b, _ := json.Marshal(p.SuggestedPostParameters); len(b) > 0 {
|
|
out["suggested_post_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyParameters != nil {
|
|
if b, _ := json.Marshal(p.ReplyParameters); len(b) > 0 {
|
|
out["reply_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyMarkup != nil {
|
|
if b, _ := json.Marshal(p.ReplyMarkup); len(b) > 0 && string(b) != "null" {
|
|
out["reply_markup"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SendAnimationParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.Animation != nil && p.Animation.IsLocalUpload() {
|
|
name := p.Animation.Filename
|
|
if name == "" {
|
|
name = "animation"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "animation", Filename: name, Reader: p.Animation.Reader})
|
|
}
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
name := p.Thumbnail.Filename
|
|
if name == "" {
|
|
name = "thumbnail"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "thumbnail", Filename: name, Reader: p.Thumbnail.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SendAnimation calls the sendAnimation Telegram Bot API method.
|
|
//
|
|
// Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
|
|
func SendAnimation(ctx context.Context, b *client.Bot, p *SendAnimationParams) (*Message, error) {
|
|
return client.Call[*SendAnimationParams, *Message](ctx, b, "sendAnimation", p)
|
|
}
|
|
|
|
// SendVoiceParams is the parameter set for SendVoice.
|
|
//
|
|
// Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
|
|
type SendVoiceParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// 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 *InputFile `json:"voice"`
|
|
// Voice message caption, 0-1024 characters after entities parsing
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the voice message caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// 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 of the voice message in seconds
|
|
Duration *int64 `json:"duration,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SendVoiceParams) HasFile() bool {
|
|
if p.Voice != nil && p.Voice.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SendVoiceParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
out["chat_id"] = p.ChatID.String()
|
|
if p.MessageThreadID != nil {
|
|
out["message_thread_id"] = strconv.FormatInt(*p.MessageThreadID, 10)
|
|
}
|
|
if p.DirectMessagesTopicID != nil {
|
|
out["direct_messages_topic_id"] = strconv.FormatInt(*p.DirectMessagesTopicID, 10)
|
|
}
|
|
if p.Caption != "" {
|
|
out["caption"] = p.Caption
|
|
}
|
|
if p.ParseMode != "" {
|
|
out["parse_mode"] = string(p.ParseMode)
|
|
}
|
|
if p.CaptionEntities != nil {
|
|
if b, _ := json.Marshal(p.CaptionEntities); len(b) > 0 {
|
|
out["caption_entities"] = string(b)
|
|
}
|
|
}
|
|
if p.Duration != nil {
|
|
out["duration"] = strconv.FormatInt(*p.Duration, 10)
|
|
}
|
|
if p.DisableNotification != nil {
|
|
out["disable_notification"] = strconv.FormatBool(*p.DisableNotification)
|
|
}
|
|
if p.ProtectContent != nil {
|
|
out["protect_content"] = strconv.FormatBool(*p.ProtectContent)
|
|
}
|
|
if p.AllowPaidBroadcast != nil {
|
|
out["allow_paid_broadcast"] = strconv.FormatBool(*p.AllowPaidBroadcast)
|
|
}
|
|
if p.MessageEffectID != "" {
|
|
out["message_effect_id"] = p.MessageEffectID
|
|
}
|
|
if p.SuggestedPostParameters != nil {
|
|
if b, _ := json.Marshal(p.SuggestedPostParameters); len(b) > 0 {
|
|
out["suggested_post_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyParameters != nil {
|
|
if b, _ := json.Marshal(p.ReplyParameters); len(b) > 0 {
|
|
out["reply_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyMarkup != nil {
|
|
if b, _ := json.Marshal(p.ReplyMarkup); len(b) > 0 && string(b) != "null" {
|
|
out["reply_markup"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SendVoiceParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.Voice != nil && p.Voice.IsLocalUpload() {
|
|
name := p.Voice.Filename
|
|
if name == "" {
|
|
name = "voice"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "voice", Filename: name, Reader: p.Voice.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SendVoice calls the sendVoice Telegram Bot API method.
|
|
//
|
|
// Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
|
|
func SendVoice(ctx context.Context, b *client.Bot, p *SendVoiceParams) (*Message, error) {
|
|
return client.Call[*SendVoiceParams, *Message](ctx, b, "sendVoice", p)
|
|
}
|
|
|
|
// SendVideoNoteParams is the parameter set for SendVideoNote.
|
|
//
|
|
// As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.
|
|
type SendVideoNoteParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// 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 *InputFile `json:"video_note"`
|
|
// Duration of sent video in seconds
|
|
Duration *int64 `json:"duration,omitempty"`
|
|
// Video width and height, i.e. diameter of the video message
|
|
Length *int64 `json:"length,omitempty"`
|
|
// 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 *InputFile `json:"thumbnail,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SendVideoNoteParams) HasFile() bool {
|
|
if p.VideoNote != nil && p.VideoNote.IsLocalUpload() {
|
|
return true
|
|
}
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SendVideoNoteParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
out["chat_id"] = p.ChatID.String()
|
|
if p.MessageThreadID != nil {
|
|
out["message_thread_id"] = strconv.FormatInt(*p.MessageThreadID, 10)
|
|
}
|
|
if p.DirectMessagesTopicID != nil {
|
|
out["direct_messages_topic_id"] = strconv.FormatInt(*p.DirectMessagesTopicID, 10)
|
|
}
|
|
if p.Duration != nil {
|
|
out["duration"] = strconv.FormatInt(*p.Duration, 10)
|
|
}
|
|
if p.Length != nil {
|
|
out["length"] = strconv.FormatInt(*p.Length, 10)
|
|
}
|
|
if p.DisableNotification != nil {
|
|
out["disable_notification"] = strconv.FormatBool(*p.DisableNotification)
|
|
}
|
|
if p.ProtectContent != nil {
|
|
out["protect_content"] = strconv.FormatBool(*p.ProtectContent)
|
|
}
|
|
if p.AllowPaidBroadcast != nil {
|
|
out["allow_paid_broadcast"] = strconv.FormatBool(*p.AllowPaidBroadcast)
|
|
}
|
|
if p.MessageEffectID != "" {
|
|
out["message_effect_id"] = p.MessageEffectID
|
|
}
|
|
if p.SuggestedPostParameters != nil {
|
|
if b, _ := json.Marshal(p.SuggestedPostParameters); len(b) > 0 {
|
|
out["suggested_post_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyParameters != nil {
|
|
if b, _ := json.Marshal(p.ReplyParameters); len(b) > 0 {
|
|
out["reply_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyMarkup != nil {
|
|
if b, _ := json.Marshal(p.ReplyMarkup); len(b) > 0 && string(b) != "null" {
|
|
out["reply_markup"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SendVideoNoteParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.VideoNote != nil && p.VideoNote.IsLocalUpload() {
|
|
name := p.VideoNote.Filename
|
|
if name == "" {
|
|
name = "video_note"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "video_note", Filename: name, Reader: p.VideoNote.Reader})
|
|
}
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
name := p.Thumbnail.Filename
|
|
if name == "" {
|
|
name = "thumbnail"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "thumbnail", Filename: name, Reader: p.Thumbnail.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SendVideoNote calls the sendVideoNote Telegram Bot API method.
|
|
//
|
|
// As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.
|
|
func SendVideoNote(ctx context.Context, b *client.Bot, p *SendVideoNoteParams) (*Message, error) {
|
|
return client.Call[*SendVideoNoteParams, *Message](ctx, b, "sendVideoNote", p)
|
|
}
|
|
|
|
// SendPaidMediaParams is the parameter set for SendPaidMedia.
|
|
//
|
|
// Use this method to send paid media. On success, the sent Message is returned.
|
|
type SendPaidMediaParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// 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 ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// The number of Telegram Stars that must be paid to buy access to the media; 1-25000
|
|
StarCount int64 `json:"star_count"`
|
|
// A JSON-serialized array describing the media to be sent; up to 10 items
|
|
Media []InputPaidMedia `json:"media"`
|
|
// 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"`
|
|
// Media caption, 0-1024 characters after entities parsing
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the media caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// 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"`
|
|
// Pass True, if the caption must be shown above the message media
|
|
ShowCaptionAboveMedia *bool `json:"show_caption_above_media,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SendPaidMediaParams) HasFile() bool {
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SendPaidMediaParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
out["chat_id"] = p.ChatID.String()
|
|
if p.MessageThreadID != nil {
|
|
out["message_thread_id"] = strconv.FormatInt(*p.MessageThreadID, 10)
|
|
}
|
|
if p.DirectMessagesTopicID != nil {
|
|
out["direct_messages_topic_id"] = strconv.FormatInt(*p.DirectMessagesTopicID, 10)
|
|
}
|
|
out["star_count"] = strconv.FormatInt(p.StarCount, 10)
|
|
if b, _ := json.Marshal(p.Media); len(b) > 0 {
|
|
out["media"] = string(b)
|
|
}
|
|
if p.Payload != "" {
|
|
out["payload"] = p.Payload
|
|
}
|
|
if p.Caption != "" {
|
|
out["caption"] = p.Caption
|
|
}
|
|
if p.ParseMode != "" {
|
|
out["parse_mode"] = string(p.ParseMode)
|
|
}
|
|
if p.CaptionEntities != nil {
|
|
if b, _ := json.Marshal(p.CaptionEntities); len(b) > 0 {
|
|
out["caption_entities"] = string(b)
|
|
}
|
|
}
|
|
if p.ShowCaptionAboveMedia != nil {
|
|
out["show_caption_above_media"] = strconv.FormatBool(*p.ShowCaptionAboveMedia)
|
|
}
|
|
if p.DisableNotification != nil {
|
|
out["disable_notification"] = strconv.FormatBool(*p.DisableNotification)
|
|
}
|
|
if p.ProtectContent != nil {
|
|
out["protect_content"] = strconv.FormatBool(*p.ProtectContent)
|
|
}
|
|
if p.AllowPaidBroadcast != nil {
|
|
out["allow_paid_broadcast"] = strconv.FormatBool(*p.AllowPaidBroadcast)
|
|
}
|
|
if p.SuggestedPostParameters != nil {
|
|
if b, _ := json.Marshal(p.SuggestedPostParameters); len(b) > 0 {
|
|
out["suggested_post_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyParameters != nil {
|
|
if b, _ := json.Marshal(p.ReplyParameters); len(b) > 0 {
|
|
out["reply_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyMarkup != nil {
|
|
if b, _ := json.Marshal(p.ReplyMarkup); len(b) > 0 && string(b) != "null" {
|
|
out["reply_markup"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SendPaidMediaParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
return files
|
|
}
|
|
|
|
// SendPaidMedia calls the sendPaidMedia Telegram Bot API method.
|
|
//
|
|
// Use this method to send paid media. On success, the sent Message is returned.
|
|
func SendPaidMedia(ctx context.Context, b *client.Bot, p *SendPaidMediaParams) (*Message, error) {
|
|
return client.Call[*SendPaidMediaParams, *Message](ctx, b, "sendPaidMedia", p)
|
|
}
|
|
|
|
// SendMediaGroupParams is the parameter set for SendMediaGroup.
|
|
//
|
|
// Use this method to send a group of photos, live photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Message objects that were sent is returned.
|
|
type SendMediaGroupParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// A JSON-serialized array describing messages to be sent, must include 2-10 items
|
|
Media []any `json:"media"`
|
|
// Sends messages silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent messages from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SendMediaGroupParams) HasFile() bool {
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SendMediaGroupParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
out["chat_id"] = p.ChatID.String()
|
|
if p.MessageThreadID != nil {
|
|
out["message_thread_id"] = strconv.FormatInt(*p.MessageThreadID, 10)
|
|
}
|
|
if p.DirectMessagesTopicID != nil {
|
|
out["direct_messages_topic_id"] = strconv.FormatInt(*p.DirectMessagesTopicID, 10)
|
|
}
|
|
if b, _ := json.Marshal(p.Media); len(b) > 0 {
|
|
out["media"] = string(b)
|
|
}
|
|
if p.DisableNotification != nil {
|
|
out["disable_notification"] = strconv.FormatBool(*p.DisableNotification)
|
|
}
|
|
if p.ProtectContent != nil {
|
|
out["protect_content"] = strconv.FormatBool(*p.ProtectContent)
|
|
}
|
|
if p.AllowPaidBroadcast != nil {
|
|
out["allow_paid_broadcast"] = strconv.FormatBool(*p.AllowPaidBroadcast)
|
|
}
|
|
if p.MessageEffectID != "" {
|
|
out["message_effect_id"] = p.MessageEffectID
|
|
}
|
|
if p.ReplyParameters != nil {
|
|
if b, _ := json.Marshal(p.ReplyParameters); len(b) > 0 {
|
|
out["reply_parameters"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SendMediaGroupParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
return files
|
|
}
|
|
|
|
// SendMediaGroup calls the sendMediaGroup Telegram Bot API method.
|
|
//
|
|
// Use this method to send a group of photos, live photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Message objects that were sent is returned.
|
|
func SendMediaGroup(ctx context.Context, b *client.Bot, p *SendMediaGroupParams) ([]Message, error) {
|
|
return client.Call[*SendMediaGroupParams, []Message](ctx, b, "sendMediaGroup", p)
|
|
}
|
|
|
|
// SendLocationParams is the parameter set for SendLocation.
|
|
//
|
|
// Use this method to send point on the map. On success, the sent Message is returned.
|
|
type SendLocationParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// Latitude of the location
|
|
Latitude float64 `json:"latitude"`
|
|
// Longitude of the location
|
|
Longitude float64 `json:"longitude"`
|
|
// The radius of uncertainty for the location, measured in meters; 0-1500
|
|
HorizontalAccuracy *float64 `json:"horizontal_accuracy,omitempty"`
|
|
// Period in seconds during which the location will be updated (see Live Locations, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely
|
|
LivePeriod *int64 `json:"live_period,omitempty"`
|
|
// For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
|
|
Heading *int64 `json:"heading,omitempty"`
|
|
// For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
|
|
ProximityAlertRadius *int64 `json:"proximity_alert_radius,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// SendLocation calls the sendLocation Telegram Bot API method.
|
|
//
|
|
// Use this method to send point on the map. On success, the sent Message is returned.
|
|
func SendLocation(ctx context.Context, b *client.Bot, p *SendLocationParams) (*Message, error) {
|
|
return client.Call[*SendLocationParams, *Message](ctx, b, "sendLocation", p)
|
|
}
|
|
|
|
// SendVenueParams is the parameter set for SendVenue.
|
|
//
|
|
// Use this method to send information about a venue. On success, the sent Message is returned.
|
|
type SendVenueParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// Latitude of the venue
|
|
Latitude float64 `json:"latitude"`
|
|
// Longitude of the venue
|
|
Longitude float64 `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"`
|
|
// Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
|
|
FoursquareType string `json:"foursquare_type,omitempty"`
|
|
// Google Places identifier of the venue
|
|
GooglePlaceID string `json:"google_place_id,omitempty"`
|
|
// Google Places type of the venue. (See supported types.)
|
|
GooglePlaceType string `json:"google_place_type,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// SendVenue calls the sendVenue Telegram Bot API method.
|
|
//
|
|
// Use this method to send information about a venue. On success, the sent Message is returned.
|
|
func SendVenue(ctx context.Context, b *client.Bot, p *SendVenueParams) (*Message, error) {
|
|
return client.Call[*SendVenueParams, *Message](ctx, b, "sendVenue", p)
|
|
}
|
|
|
|
// SendContactParams is the parameter set for SendContact.
|
|
//
|
|
// Use this method to send phone contacts. On success, the sent Message is returned.
|
|
type SendContactParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// Contact's phone number
|
|
PhoneNumber string `json:"phone_number"`
|
|
// Contact's first name
|
|
FirstName string `json:"first_name"`
|
|
// Contact's last name
|
|
LastName string `json:"last_name,omitempty"`
|
|
// Additional data about the contact in the form of a vCard, 0-2048 bytes
|
|
Vcard string `json:"vcard,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// SendContact calls the sendContact Telegram Bot API method.
|
|
//
|
|
// Use this method to send phone contacts. On success, the sent Message is returned.
|
|
func SendContact(ctx context.Context, b *client.Bot, p *SendContactParams) (*Message, error) {
|
|
return client.Call[*SendContactParams, *Message](ctx, b, "sendContact", p)
|
|
}
|
|
|
|
// SendPollParams is the parameter set for SendPoll.
|
|
//
|
|
// Use this method to send a native poll. On success, the sent Message is returned.
|
|
type SendPollParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username. Polls can't be sent to channel direct messages chats.
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// Poll question, 1-300 characters
|
|
Question string `json:"question"`
|
|
// Mode for parsing entities in the question. See formatting options for more details. Currently, only custom emoji entities are allowed.
|
|
QuestionParseMode ParseMode `json:"question_parse_mode,omitempty"`
|
|
// A JSON-serialized list of special entities that appear in the poll question. It can be specified instead of question_parse_mode.
|
|
QuestionEntities []MessageEntity `json:"question_entities,omitempty"`
|
|
// A JSON-serialized list of 1-12 answer options
|
|
Options []InputPollOption `json:"options"`
|
|
// True, if the poll needs to be anonymous, defaults to True
|
|
IsAnonymous *bool `json:"is_anonymous,omitempty"`
|
|
// Poll type, “quiz” or “regular”, defaults to “regular”
|
|
Type string `json:"type,omitempty"`
|
|
// Pass True, if the poll allows multiple answers, defaults to False
|
|
AllowsMultipleAnswers *bool `json:"allows_multiple_answers,omitempty"`
|
|
// Pass True, if the poll allows to change chosen answer options, defaults to False for quizzes and to True for regular polls
|
|
AllowsRevoting *bool `json:"allows_revoting,omitempty"`
|
|
// Pass True, if the poll options must be shown in random order
|
|
ShuffleOptions *bool `json:"shuffle_options,omitempty"`
|
|
// Pass True, if answer options can be added to the poll after creation; not supported for anonymous polls and quizzes
|
|
AllowAddingOptions *bool `json:"allow_adding_options,omitempty"`
|
|
// Pass True, if poll results must be shown only after the poll closes
|
|
HideResultsUntilCloses *bool `json:"hide_results_until_closes,omitempty"`
|
|
// Pass True, if voting is limited to users who have been members of the chat where the poll is being sent for more than 24 hours; for channel chats only
|
|
MembersOnly *bool `json:"members_only,omitempty"`
|
|
// A JSON-serialized list of 0-12 two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which users can vote in the poll; for channel chats only. Use “FT” as a country code to allow users with anonymous numbers to vote. If omitted or empty, then users from any country can participate in the poll.
|
|
CountryCodes []string `json:"country_codes,omitempty"`
|
|
// A JSON-serialized list of monotonically increasing 0-based identifiers of the correct answer options, required for polls in quiz mode
|
|
CorrectOptionIds []int64 `json:"correct_option_ids,omitempty"`
|
|
// Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing
|
|
Explanation string `json:"explanation,omitempty"`
|
|
// Mode for parsing entities in the explanation. See formatting options for more details.
|
|
ExplanationParseMode ParseMode `json:"explanation_parse_mode,omitempty"`
|
|
// A JSON-serialized list of special entities that appear in the poll explanation. It can be specified instead of explanation_parse_mode.
|
|
ExplanationEntities []MessageEntity `json:"explanation_entities,omitempty"`
|
|
// Media added to the quiz explanation
|
|
ExplanationMedia InputPollMedia `json:"explanation_media,omitempty"`
|
|
// Amount of time in seconds the poll will be active after creation, 5-2628000. Can't be used together with close_date.
|
|
OpenPeriod *int64 `json:"open_period,omitempty"`
|
|
// Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 2628000 seconds in the future. Can't be used together with open_period.
|
|
CloseDate *int64 `json:"close_date,omitempty"`
|
|
// Pass True if the poll needs to be immediately closed. This can be useful for poll preview.
|
|
IsClosed *bool `json:"is_closed,omitempty"`
|
|
// Description of the poll to be sent, 0-1024 characters after entities parsing
|
|
Description string `json:"description,omitempty"`
|
|
// Mode for parsing entities in the poll description. See formatting options for more details.
|
|
DescriptionParseMode ParseMode `json:"description_parse_mode,omitempty"`
|
|
// A JSON-serialized list of special entities that appear in the poll description, which can be specified instead of description_parse_mode
|
|
DescriptionEntities []MessageEntity `json:"description_entities,omitempty"`
|
|
// Media added to the poll description
|
|
Media InputPollMedia `json:"media,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// SendPoll calls the sendPoll Telegram Bot API method.
|
|
//
|
|
// Use this method to send a native poll. On success, the sent Message is returned.
|
|
func SendPoll(ctx context.Context, b *client.Bot, p *SendPollParams) (*Message, error) {
|
|
return client.Call[*SendPollParams, *Message](ctx, b, "sendPoll", p)
|
|
}
|
|
|
|
// SendChecklistParams is the parameter set for SendChecklist.
|
|
//
|
|
// Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned.
|
|
type SendChecklistParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Unique identifier for the target chat or username of the target bot in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// A JSON-serialized object for the checklist to send
|
|
Checklist InputChecklist `json:"checklist"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// Unique identifier of the message effect to be added to the message
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// A JSON-serialized object for description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// A JSON-serialized object for an inline keyboard
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// SendChecklist calls the sendChecklist Telegram Bot API method.
|
|
//
|
|
// Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned.
|
|
func SendChecklist(ctx context.Context, b *client.Bot, p *SendChecklistParams) (*Message, error) {
|
|
return client.Call[*SendChecklistParams, *Message](ctx, b, "sendChecklist", p)
|
|
}
|
|
|
|
// SendDiceParams is the parameter set for SendDice.
|
|
//
|
|
// Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
|
|
type SendDiceParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// Emoji on which the dice throw animation is based. Currently, must be one of “”, “”, “”, “”, “”, or “”. Dice can have values 1-6 for “”, “” and “”, values 1-5 for “” and “”, and values 1-64 for “”. Defaults to “”.
|
|
Emoji DiceEmoji `json:"emoji,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// SendDice calls the sendDice Telegram Bot API method.
|
|
//
|
|
// Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
|
|
func SendDice(ctx context.Context, b *client.Bot, p *SendDiceParams) (*Message, error) {
|
|
return client.Call[*SendDiceParams, *Message](ctx, b, "sendDice", p)
|
|
}
|
|
|
|
// SendMessageDraftParams is the parameter set for SendMessageDraft.
|
|
//
|
|
// Use this method to stream a partial message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you must call sendMessage with the complete message to persist it in the user's chat. Returns True on success.
|
|
type SendMessageDraftParams struct {
|
|
// Unique identifier for the target private chat
|
|
ChatID int64 `json:"chat_id"`
|
|
// Unique identifier for the target message thread
|
|
MessageThreadID *int64 `json:"message_thread_id,omitempty"`
|
|
// Unique identifier of the message draft; must be non-zero. Changes of drafts with the same identifier are animated.
|
|
DraftID int64 `json:"draft_id"`
|
|
// Text of the message to be sent, 0-4096 characters after entities parsing. Pass an empty text to show a “Thinking…” placeholder.
|
|
Text string `json:"text,omitempty"`
|
|
// Mode for parsing entities in the message text. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode
|
|
Entities []MessageEntity `json:"entities,omitempty"`
|
|
}
|
|
|
|
// SendMessageDraft calls the sendMessageDraft Telegram Bot API method.
|
|
//
|
|
// Use this method to stream a partial message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you must call sendMessage with the complete message to persist it in the user's chat. Returns True on success.
|
|
func SendMessageDraft(ctx context.Context, b *client.Bot, p *SendMessageDraftParams) (bool, error) {
|
|
return client.Call[*SendMessageDraftParams, bool](ctx, b, "sendMessageDraft", p)
|
|
}
|
|
|
|
// SendChatActionParams is the parameter set for SendChatAction.
|
|
//
|
|
// Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
|
|
// Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.
|
|
// We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
|
|
type SendChatActionParams struct {
|
|
// Unique identifier of the business connection on behalf of which the action will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot or supergroup in the format @username. Channel chats and channel direct messages chats aren't supported.
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier for the target message thread or topic of a forum; for supergroups and private chats of bots with forum topic mode enabled only
|
|
MessageThreadID *int64 `json:"message_thread_id,omitempty"`
|
|
// Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
|
|
Action string `json:"action"`
|
|
}
|
|
|
|
// SendChatAction calls the sendChatAction Telegram Bot API method.
|
|
//
|
|
// Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
|
|
// Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.
|
|
// We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
|
|
func SendChatAction(ctx context.Context, b *client.Bot, p *SendChatActionParams) (bool, error) {
|
|
return client.Call[*SendChatActionParams, bool](ctx, b, "sendChatAction", p)
|
|
}
|
|
|
|
// SetMessageReactionParams is the parameter set for SetMessageReaction.
|
|
//
|
|
// Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success.
|
|
type SetMessageReactionParams struct {
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Identifier of the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead.
|
|
MessageID int64 `json:"message_id"`
|
|
// A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
|
|
Reaction []ReactionType `json:"reaction,omitempty"`
|
|
// Pass True to set the reaction with a big animation
|
|
IsBig *bool `json:"is_big,omitempty"`
|
|
}
|
|
|
|
// SetMessageReaction calls the setMessageReaction Telegram Bot API method.
|
|
//
|
|
// Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success.
|
|
func SetMessageReaction(ctx context.Context, b *client.Bot, p *SetMessageReactionParams) (bool, error) {
|
|
return client.Call[*SetMessageReactionParams, bool](ctx, b, "setMessageReaction", p)
|
|
}
|
|
|
|
// GetUserProfilePhotosParams is the parameter set for GetUserProfilePhotos.
|
|
//
|
|
// Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
|
|
type GetUserProfilePhotosParams struct {
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
// Sequential number of the first photo to be returned. By default, all photos are returned.
|
|
Offset *int64 `json:"offset,omitempty"`
|
|
// Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to 100.
|
|
Limit *int64 `json:"limit,omitempty"`
|
|
}
|
|
|
|
// GetUserProfilePhotos calls the getUserProfilePhotos Telegram Bot API method.
|
|
//
|
|
// Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
|
|
func GetUserProfilePhotos(ctx context.Context, b *client.Bot, p *GetUserProfilePhotosParams) (*UserProfilePhotos, error) {
|
|
return client.Call[*GetUserProfilePhotosParams, *UserProfilePhotos](ctx, b, "getUserProfilePhotos", p)
|
|
}
|
|
|
|
// GetUserProfileAudiosParams is the parameter set for GetUserProfileAudios.
|
|
//
|
|
// Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object.
|
|
type GetUserProfileAudiosParams struct {
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
// Sequential number of the first audio to be returned. By default, all audios are returned.
|
|
Offset *int64 `json:"offset,omitempty"`
|
|
// Limits the number of audios to be retrieved. Values between 1-100 are accepted. Defaults to 100.
|
|
Limit *int64 `json:"limit,omitempty"`
|
|
}
|
|
|
|
// GetUserProfileAudios calls the getUserProfileAudios Telegram Bot API method.
|
|
//
|
|
// Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object.
|
|
func GetUserProfileAudios(ctx context.Context, b *client.Bot, p *GetUserProfileAudiosParams) (*UserProfileAudios, error) {
|
|
return client.Call[*GetUserProfileAudiosParams, *UserProfileAudios](ctx, b, "getUserProfileAudios", p)
|
|
}
|
|
|
|
// SetUserEmojiStatusParams is the parameter set for SetUserEmojiStatus.
|
|
//
|
|
// Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.
|
|
type SetUserEmojiStatusParams struct {
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
// Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.
|
|
EmojiStatusCustomEmojiID string `json:"emoji_status_custom_emoji_id,omitempty"`
|
|
// Expiration date of the emoji status, if any
|
|
EmojiStatusExpirationDate *int64 `json:"emoji_status_expiration_date,omitempty"`
|
|
}
|
|
|
|
// SetUserEmojiStatus calls the setUserEmojiStatus Telegram Bot API method.
|
|
//
|
|
// Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.
|
|
func SetUserEmojiStatus(ctx context.Context, b *client.Bot, p *SetUserEmojiStatusParams) (bool, error) {
|
|
return client.Call[*SetUserEmojiStatusParams, bool](ctx, b, "setUserEmojiStatus", p)
|
|
}
|
|
|
|
// GetFileParams is the parameter set for GetFile.
|
|
//
|
|
// Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.
|
|
// Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
|
|
type GetFileParams struct {
|
|
// File identifier to get information about
|
|
FileID string `json:"file_id"`
|
|
}
|
|
|
|
// GetFile calls the getFile Telegram Bot API method.
|
|
//
|
|
// Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.
|
|
// Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
|
|
func GetFile(ctx context.Context, b *client.Bot, p *GetFileParams) (*File, error) {
|
|
return client.Call[*GetFileParams, *File](ctx, b, "getFile", p)
|
|
}
|
|
|
|
// BanChatMemberParams is the parameter set for BanChatMember.
|
|
//
|
|
// Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
type BanChatMemberParams struct {
|
|
// Unique identifier for the target group or username of the target supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
// Date when the user will be unbanned; Unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only.
|
|
UntilDate *int64 `json:"until_date,omitempty"`
|
|
// Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels.
|
|
RevokeMessages *bool `json:"revoke_messages,omitempty"`
|
|
}
|
|
|
|
// BanChatMember calls the banChatMember Telegram Bot API method.
|
|
//
|
|
// Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
func BanChatMember(ctx context.Context, b *client.Bot, p *BanChatMemberParams) (bool, error) {
|
|
return client.Call[*BanChatMemberParams, bool](ctx, b, "banChatMember", p)
|
|
}
|
|
|
|
// UnbanChatMemberParams is the parameter set for UnbanChatMember.
|
|
//
|
|
// Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success.
|
|
type UnbanChatMemberParams struct {
|
|
// Unique identifier for the target group or username of the target supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
// Do nothing if the user is not banned
|
|
OnlyIfBanned *bool `json:"only_if_banned,omitempty"`
|
|
}
|
|
|
|
// UnbanChatMember calls the unbanChatMember Telegram Bot API method.
|
|
//
|
|
// Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success.
|
|
func UnbanChatMember(ctx context.Context, b *client.Bot, p *UnbanChatMemberParams) (bool, error) {
|
|
return client.Call[*UnbanChatMemberParams, bool](ctx, b, "unbanChatMember", p)
|
|
}
|
|
|
|
// RestrictChatMemberParams is the parameter set for RestrictChatMember.
|
|
//
|
|
// Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.
|
|
type RestrictChatMemberParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
// A JSON-serialized object for new user permissions
|
|
Permissions ChatPermissions `json:"permissions"`
|
|
// Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.
|
|
UseIndependentChatPermissions *bool `json:"use_independent_chat_permissions,omitempty"`
|
|
// Date when restrictions will be lifted for the user; Unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever.
|
|
UntilDate *int64 `json:"until_date,omitempty"`
|
|
}
|
|
|
|
// RestrictChatMember calls the restrictChatMember Telegram Bot API method.
|
|
//
|
|
// Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.
|
|
func RestrictChatMember(ctx context.Context, b *client.Bot, p *RestrictChatMemberParams) (bool, error) {
|
|
return client.Call[*RestrictChatMemberParams, bool](ctx, b, "restrictChatMember", p)
|
|
}
|
|
|
|
// PromoteChatMemberParams is the parameter set for PromoteChatMember.
|
|
//
|
|
// Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success.
|
|
type PromoteChatMemberParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
// Pass True if the administrator's presence in the chat is hidden
|
|
IsAnonymous *bool `json:"is_anonymous,omitempty"`
|
|
// Pass True if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege.
|
|
CanManageChat *bool `json:"can_manage_chat,omitempty"`
|
|
// Pass True if the administrator can delete messages of other users
|
|
CanDeleteMessages *bool `json:"can_delete_messages,omitempty"`
|
|
// Pass True if the administrator can manage video chats
|
|
CanManageVideoChats *bool `json:"can_manage_video_chats,omitempty"`
|
|
// Pass True if the administrator can restrict, ban or unban chat members, or access supergroup statistics. For backward compatibility, defaults to True for promotions of channel administrators.
|
|
CanRestrictMembers *bool `json:"can_restrict_members,omitempty"`
|
|
// Pass True if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by him)
|
|
CanPromoteMembers *bool `json:"can_promote_members,omitempty"`
|
|
// Pass True if the administrator can change chat title, photo and other settings
|
|
CanChangeInfo *bool `json:"can_change_info,omitempty"`
|
|
// Pass True if the administrator can invite new users to the chat
|
|
CanInviteUsers *bool `json:"can_invite_users,omitempty"`
|
|
// Pass True if the administrator can post stories to the chat
|
|
CanPostStories *bool `json:"can_post_stories,omitempty"`
|
|
// Pass True if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive
|
|
CanEditStories *bool `json:"can_edit_stories,omitempty"`
|
|
// Pass True if the administrator can delete stories posted by other users
|
|
CanDeleteStories *bool `json:"can_delete_stories,omitempty"`
|
|
// Pass True if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only
|
|
CanPostMessages *bool `json:"can_post_messages,omitempty"`
|
|
// Pass True if the administrator can edit messages of other users and can pin messages; for channels only
|
|
CanEditMessages *bool `json:"can_edit_messages,omitempty"`
|
|
// Pass True if the administrator can pin messages; for supergroups only
|
|
CanPinMessages *bool `json:"can_pin_messages,omitempty"`
|
|
// Pass True if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only
|
|
CanManageTopics *bool `json:"can_manage_topics,omitempty"`
|
|
// Pass True if the administrator can manage direct messages within the channel and decline suggested posts; for channels only
|
|
CanManageDirectMessages *bool `json:"can_manage_direct_messages,omitempty"`
|
|
// Pass True if the administrator can edit the tags of regular members; for groups and supergroups only
|
|
CanManageTags *bool `json:"can_manage_tags,omitempty"`
|
|
}
|
|
|
|
// PromoteChatMember calls the promoteChatMember Telegram Bot API method.
|
|
//
|
|
// Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success.
|
|
func PromoteChatMember(ctx context.Context, b *client.Bot, p *PromoteChatMemberParams) (bool, error) {
|
|
return client.Call[*PromoteChatMemberParams, bool](ctx, b, "promoteChatMember", p)
|
|
}
|
|
|
|
// SetChatAdministratorCustomTitleParams is the parameter set for SetChatAdministratorCustomTitle.
|
|
//
|
|
// Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.
|
|
type SetChatAdministratorCustomTitleParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
// New custom title for the administrator; 0-16 characters, emoji are not allowed
|
|
CustomTitle string `json:"custom_title"`
|
|
}
|
|
|
|
// SetChatAdministratorCustomTitle calls the setChatAdministratorCustomTitle Telegram Bot API method.
|
|
//
|
|
// Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.
|
|
func SetChatAdministratorCustomTitle(ctx context.Context, b *client.Bot, p *SetChatAdministratorCustomTitleParams) (bool, error) {
|
|
return client.Call[*SetChatAdministratorCustomTitleParams, bool](ctx, b, "setChatAdministratorCustomTitle", p)
|
|
}
|
|
|
|
// SetChatMemberTagParams is the parameter set for SetChatMemberTag.
|
|
//
|
|
// Use this method to set a tag for a regular member in a group or a supergroup. The bot must be an administrator in the chat for this to work and must have the can_manage_tags administrator right. Returns True on success.
|
|
type SetChatMemberTagParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
// New tag for the member; 0-16 characters, emoji are not allowed
|
|
Tag string `json:"tag,omitempty"`
|
|
}
|
|
|
|
// SetChatMemberTag calls the setChatMemberTag Telegram Bot API method.
|
|
//
|
|
// Use this method to set a tag for a regular member in a group or a supergroup. The bot must be an administrator in the chat for this to work and must have the can_manage_tags administrator right. Returns True on success.
|
|
func SetChatMemberTag(ctx context.Context, b *client.Bot, p *SetChatMemberTagParams) (bool, error) {
|
|
return client.Call[*SetChatMemberTagParams, bool](ctx, b, "setChatMemberTag", p)
|
|
}
|
|
|
|
// BanChatSenderChatParams is the parameter set for BanChatSenderChat.
|
|
//
|
|
// Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
type BanChatSenderChatParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target sender chat
|
|
SenderChatID int64 `json:"sender_chat_id"`
|
|
}
|
|
|
|
// BanChatSenderChat calls the banChatSenderChat Telegram Bot API method.
|
|
//
|
|
// Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
func BanChatSenderChat(ctx context.Context, b *client.Bot, p *BanChatSenderChatParams) (bool, error) {
|
|
return client.Call[*BanChatSenderChatParams, bool](ctx, b, "banChatSenderChat", p)
|
|
}
|
|
|
|
// UnbanChatSenderChatParams is the parameter set for UnbanChatSenderChat.
|
|
//
|
|
// Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
type UnbanChatSenderChatParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target sender chat
|
|
SenderChatID int64 `json:"sender_chat_id"`
|
|
}
|
|
|
|
// UnbanChatSenderChat calls the unbanChatSenderChat Telegram Bot API method.
|
|
//
|
|
// Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
func UnbanChatSenderChat(ctx context.Context, b *client.Bot, p *UnbanChatSenderChatParams) (bool, error) {
|
|
return client.Call[*UnbanChatSenderChatParams, bool](ctx, b, "unbanChatSenderChat", p)
|
|
}
|
|
|
|
// SetChatPermissionsParams is the parameter set for SetChatPermissions.
|
|
//
|
|
// Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success.
|
|
type SetChatPermissionsParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// A JSON-serialized object for new default chat permissions
|
|
Permissions ChatPermissions `json:"permissions"`
|
|
// Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.
|
|
UseIndependentChatPermissions *bool `json:"use_independent_chat_permissions,omitempty"`
|
|
}
|
|
|
|
// SetChatPermissions calls the setChatPermissions Telegram Bot API method.
|
|
//
|
|
// Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success.
|
|
func SetChatPermissions(ctx context.Context, b *client.Bot, p *SetChatPermissionsParams) (bool, error) {
|
|
return client.Call[*SetChatPermissionsParams, bool](ctx, b, "setChatPermissions", p)
|
|
}
|
|
|
|
// ExportChatInviteLinkParams is the parameter set for ExportChatInviteLink.
|
|
//
|
|
// Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success.
|
|
// Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again.
|
|
type ExportChatInviteLinkParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// ExportChatInviteLink calls the exportChatInviteLink Telegram Bot API method.
|
|
//
|
|
// Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success.
|
|
// Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again.
|
|
func ExportChatInviteLink(ctx context.Context, b *client.Bot, p *ExportChatInviteLinkParams) (string, error) {
|
|
return client.Call[*ExportChatInviteLinkParams, string](ctx, b, "exportChatInviteLink", p)
|
|
}
|
|
|
|
// CreateChatInviteLinkParams is the parameter set for CreateChatInviteLink.
|
|
//
|
|
// Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object.
|
|
type CreateChatInviteLinkParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Invite link name; 0-32 characters
|
|
Name string `json:"name,omitempty"`
|
|
// Point in time (Unix timestamp) when the link will expire
|
|
ExpireDate *int64 `json:"expire_date,omitempty"`
|
|
// The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
|
|
MemberLimit *int64 `json:"member_limit,omitempty"`
|
|
// True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified.
|
|
CreatesJoinRequest *bool `json:"creates_join_request,omitempty"`
|
|
}
|
|
|
|
// CreateChatInviteLink calls the createChatInviteLink Telegram Bot API method.
|
|
//
|
|
// Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object.
|
|
func CreateChatInviteLink(ctx context.Context, b *client.Bot, p *CreateChatInviteLinkParams) (*ChatInviteLink, error) {
|
|
return client.Call[*CreateChatInviteLinkParams, *ChatInviteLink](ctx, b, "createChatInviteLink", p)
|
|
}
|
|
|
|
// EditChatInviteLinkParams is the parameter set for EditChatInviteLink.
|
|
//
|
|
// Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
type EditChatInviteLinkParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// The invite link to edit
|
|
InviteLink string `json:"invite_link"`
|
|
// Invite link name; 0-32 characters
|
|
Name string `json:"name,omitempty"`
|
|
// Point in time (Unix timestamp) when the link will expire
|
|
ExpireDate *int64 `json:"expire_date,omitempty"`
|
|
// The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
|
|
MemberLimit *int64 `json:"member_limit,omitempty"`
|
|
// True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified.
|
|
CreatesJoinRequest *bool `json:"creates_join_request,omitempty"`
|
|
}
|
|
|
|
// EditChatInviteLink calls the editChatInviteLink Telegram Bot API method.
|
|
//
|
|
// Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
func EditChatInviteLink(ctx context.Context, b *client.Bot, p *EditChatInviteLinkParams) (*ChatInviteLink, error) {
|
|
return client.Call[*EditChatInviteLinkParams, *ChatInviteLink](ctx, b, "editChatInviteLink", p)
|
|
}
|
|
|
|
// CreateChatSubscriptionInviteLinkParams is the parameter set for CreateChatSubscriptionInviteLink.
|
|
//
|
|
// Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.
|
|
type CreateChatSubscriptionInviteLinkParams struct {
|
|
// Unique identifier for the target channel chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Invite link name; 0-32 characters
|
|
Name string `json:"name,omitempty"`
|
|
// The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
|
|
SubscriptionPeriod int64 `json:"subscription_period"`
|
|
// The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-10000
|
|
SubscriptionPrice int64 `json:"subscription_price"`
|
|
}
|
|
|
|
// CreateChatSubscriptionInviteLink calls the createChatSubscriptionInviteLink Telegram Bot API method.
|
|
//
|
|
// Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.
|
|
func CreateChatSubscriptionInviteLink(ctx context.Context, b *client.Bot, p *CreateChatSubscriptionInviteLinkParams) (*ChatInviteLink, error) {
|
|
return client.Call[*CreateChatSubscriptionInviteLinkParams, *ChatInviteLink](ctx, b, "createChatSubscriptionInviteLink", p)
|
|
}
|
|
|
|
// EditChatSubscriptionInviteLinkParams is the parameter set for EditChatSubscriptionInviteLink.
|
|
//
|
|
// Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
type EditChatSubscriptionInviteLinkParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// The invite link to edit
|
|
InviteLink string `json:"invite_link"`
|
|
// Invite link name; 0-32 characters
|
|
Name string `json:"name,omitempty"`
|
|
}
|
|
|
|
// EditChatSubscriptionInviteLink calls the editChatSubscriptionInviteLink Telegram Bot API method.
|
|
//
|
|
// Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
func EditChatSubscriptionInviteLink(ctx context.Context, b *client.Bot, p *EditChatSubscriptionInviteLinkParams) (*ChatInviteLink, error) {
|
|
return client.Call[*EditChatSubscriptionInviteLinkParams, *ChatInviteLink](ctx, b, "editChatSubscriptionInviteLink", p)
|
|
}
|
|
|
|
// RevokeChatInviteLinkParams is the parameter set for RevokeChatInviteLink.
|
|
//
|
|
// Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
|
|
type RevokeChatInviteLinkParams struct {
|
|
// Unique identifier of the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// The invite link to revoke
|
|
InviteLink string `json:"invite_link"`
|
|
}
|
|
|
|
// RevokeChatInviteLink calls the revokeChatInviteLink Telegram Bot API method.
|
|
//
|
|
// Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
|
|
func RevokeChatInviteLink(ctx context.Context, b *client.Bot, p *RevokeChatInviteLinkParams) (*ChatInviteLink, error) {
|
|
return client.Call[*RevokeChatInviteLinkParams, *ChatInviteLink](ctx, b, "revokeChatInviteLink", p)
|
|
}
|
|
|
|
// ApproveChatJoinRequestParams is the parameter set for ApproveChatJoinRequest.
|
|
//
|
|
// Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.
|
|
type ApproveChatJoinRequestParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
}
|
|
|
|
// ApproveChatJoinRequest calls the approveChatJoinRequest Telegram Bot API method.
|
|
//
|
|
// Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.
|
|
func ApproveChatJoinRequest(ctx context.Context, b *client.Bot, p *ApproveChatJoinRequestParams) (bool, error) {
|
|
return client.Call[*ApproveChatJoinRequestParams, bool](ctx, b, "approveChatJoinRequest", p)
|
|
}
|
|
|
|
// DeclineChatJoinRequestParams is the parameter set for DeclineChatJoinRequest.
|
|
//
|
|
// Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.
|
|
type DeclineChatJoinRequestParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
}
|
|
|
|
// DeclineChatJoinRequest calls the declineChatJoinRequest Telegram Bot API method.
|
|
//
|
|
// Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.
|
|
func DeclineChatJoinRequest(ctx context.Context, b *client.Bot, p *DeclineChatJoinRequestParams) (bool, error) {
|
|
return client.Call[*DeclineChatJoinRequestParams, bool](ctx, b, "declineChatJoinRequest", p)
|
|
}
|
|
|
|
// SetChatPhotoParams is the parameter set for SetChatPhoto.
|
|
//
|
|
// Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
type SetChatPhotoParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// New chat photo, uploaded using multipart/form-data
|
|
Photo *InputFile `json:"photo"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SetChatPhotoParams) HasFile() bool {
|
|
if p.Photo != nil && p.Photo.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SetChatPhotoParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
out["chat_id"] = p.ChatID.String()
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SetChatPhotoParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.Photo != nil && p.Photo.IsLocalUpload() {
|
|
name := p.Photo.Filename
|
|
if name == "" {
|
|
name = "photo"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "photo", Filename: name, Reader: p.Photo.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SetChatPhoto calls the setChatPhoto Telegram Bot API method.
|
|
//
|
|
// Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
func SetChatPhoto(ctx context.Context, b *client.Bot, p *SetChatPhotoParams) (bool, error) {
|
|
return client.Call[*SetChatPhotoParams, bool](ctx, b, "setChatPhoto", p)
|
|
}
|
|
|
|
// DeleteChatPhotoParams is the parameter set for DeleteChatPhoto.
|
|
//
|
|
// Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
type DeleteChatPhotoParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// DeleteChatPhoto calls the deleteChatPhoto Telegram Bot API method.
|
|
//
|
|
// Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
func DeleteChatPhoto(ctx context.Context, b *client.Bot, p *DeleteChatPhotoParams) (bool, error) {
|
|
return client.Call[*DeleteChatPhotoParams, bool](ctx, b, "deleteChatPhoto", p)
|
|
}
|
|
|
|
// SetChatTitleParams is the parameter set for SetChatTitle.
|
|
//
|
|
// Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
type SetChatTitleParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// New chat title, 1-128 characters
|
|
Title string `json:"title"`
|
|
}
|
|
|
|
// SetChatTitle calls the setChatTitle Telegram Bot API method.
|
|
//
|
|
// Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
func SetChatTitle(ctx context.Context, b *client.Bot, p *SetChatTitleParams) (bool, error) {
|
|
return client.Call[*SetChatTitleParams, bool](ctx, b, "setChatTitle", p)
|
|
}
|
|
|
|
// SetChatDescriptionParams is the parameter set for SetChatDescription.
|
|
//
|
|
// Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
type SetChatDescriptionParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// New chat description, 0-255 characters
|
|
Description string `json:"description,omitempty"`
|
|
}
|
|
|
|
// SetChatDescription calls the setChatDescription Telegram Bot API method.
|
|
//
|
|
// Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
func SetChatDescription(ctx context.Context, b *client.Bot, p *SetChatDescriptionParams) (bool, error) {
|
|
return client.Call[*SetChatDescriptionParams, bool](ctx, b, "setChatDescription", p)
|
|
}
|
|
|
|
// PinChatMessageParams is the parameter set for PinChatMessage.
|
|
//
|
|
// Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns True on success.
|
|
type PinChatMessageParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be pinned
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Identifier of a message to pin
|
|
MessageID int64 `json:"message_id"`
|
|
// Pass True if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
}
|
|
|
|
// PinChatMessage calls the pinChatMessage Telegram Bot API method.
|
|
//
|
|
// Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns True on success.
|
|
func PinChatMessage(ctx context.Context, b *client.Bot, p *PinChatMessageParams) (bool, error) {
|
|
return client.Call[*PinChatMessageParams, bool](ctx, b, "pinChatMessage", p)
|
|
}
|
|
|
|
// UnpinChatMessageParams is the parameter set for UnpinChatMessage.
|
|
//
|
|
// Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin messages in groups and channels respectively. Returns True on success.
|
|
type UnpinChatMessageParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be unpinned
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Identifier of the message to unpin. Required if business_connection_id is specified. If not specified, the most recent pinned message (by sending date) will be unpinned.
|
|
MessageID *int64 `json:"message_id,omitempty"`
|
|
}
|
|
|
|
// UnpinChatMessage calls the unpinChatMessage Telegram Bot API method.
|
|
//
|
|
// Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin messages in groups and channels respectively. Returns True on success.
|
|
func UnpinChatMessage(ctx context.Context, b *client.Bot, p *UnpinChatMessageParams) (bool, error) {
|
|
return client.Call[*UnpinChatMessageParams, bool](ctx, b, "unpinChatMessage", p)
|
|
}
|
|
|
|
// UnpinAllChatMessagesParams is the parameter set for UnpinAllChatMessages.
|
|
//
|
|
// Use this method to clear the list of pinned messages in a chat. In private chats and channel direct messages chats, no additional rights are required to unpin all pinned messages. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin all pinned messages in groups and channels respectively. Returns True on success.
|
|
type UnpinAllChatMessagesParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// UnpinAllChatMessages calls the unpinAllChatMessages Telegram Bot API method.
|
|
//
|
|
// Use this method to clear the list of pinned messages in a chat. In private chats and channel direct messages chats, no additional rights are required to unpin all pinned messages. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin all pinned messages in groups and channels respectively. Returns True on success.
|
|
func UnpinAllChatMessages(ctx context.Context, b *client.Bot, p *UnpinAllChatMessagesParams) (bool, error) {
|
|
return client.Call[*UnpinAllChatMessagesParams, bool](ctx, b, "unpinAllChatMessages", p)
|
|
}
|
|
|
|
// LeaveChatParams is the parameter set for LeaveChat.
|
|
//
|
|
// Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
|
|
type LeaveChatParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup or channel in the format @username. Channel direct messages chats aren't supported; leave the corresponding channel instead.
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// LeaveChat calls the leaveChat Telegram Bot API method.
|
|
//
|
|
// Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
|
|
func LeaveChat(ctx context.Context, b *client.Bot, p *LeaveChatParams) (bool, error) {
|
|
return client.Call[*LeaveChatParams, bool](ctx, b, "leaveChat", p)
|
|
}
|
|
|
|
// GetChatParams is the parameter set for GetChat.
|
|
//
|
|
// Use this method to get up-to-date information about the chat. Returns a ChatFullInfo object on success.
|
|
type GetChatParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// GetChat calls the getChat Telegram Bot API method.
|
|
//
|
|
// Use this method to get up-to-date information about the chat. Returns a ChatFullInfo object on success.
|
|
func GetChat(ctx context.Context, b *client.Bot, p *GetChatParams) (*ChatFullInfo, error) {
|
|
return client.Call[*GetChatParams, *ChatFullInfo](ctx, b, "getChat", p)
|
|
}
|
|
|
|
// GetChatAdministratorsParams is the parameter set for GetChatAdministrators.
|
|
//
|
|
// Use this method to get a list of administrators in a chat. Returns an Array of ChatMember objects.
|
|
type GetChatAdministratorsParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Pass True to additionally receive all bots that are administrators of the chat. By default, bots other than the current bot are omitted.
|
|
ReturnBots *bool `json:"return_bots,omitempty"`
|
|
}
|
|
|
|
// GetChatAdministrators calls the getChatAdministrators Telegram Bot API method.
|
|
//
|
|
// Use this method to get a list of administrators in a chat. Returns an Array of ChatMember objects.
|
|
func GetChatAdministrators(ctx context.Context, b *client.Bot, p *GetChatAdministratorsParams) ([]ChatMember, error) {
|
|
raw, err := client.CallRaw[*GetChatAdministratorsParams](ctx, b, "getChatAdministrators", p)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var elems []json.RawMessage
|
|
if err := json.Unmarshal(raw, &elems); err != nil {
|
|
return nil, err
|
|
}
|
|
out := make([]ChatMember, 0, len(elems))
|
|
for _, e := range elems {
|
|
v, err := UnmarshalChatMember(e)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out = append(out, v)
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
// GetChatMemberCountParams is the parameter set for GetChatMemberCount.
|
|
//
|
|
// Use this method to get the number of members in a chat. Returns Int on success.
|
|
type GetChatMemberCountParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// GetChatMemberCount calls the getChatMemberCount Telegram Bot API method.
|
|
//
|
|
// Use this method to get the number of members in a chat. Returns Int on success.
|
|
func GetChatMemberCount(ctx context.Context, b *client.Bot, p *GetChatMemberCountParams) (int64, error) {
|
|
return client.Call[*GetChatMemberCountParams, int64](ctx, b, "getChatMemberCount", p)
|
|
}
|
|
|
|
// GetChatMemberParams is the parameter set for GetChatMember.
|
|
//
|
|
// Use this method to get information about a member of a chat. The method is only guaranteed to work for other users if the bot is an administrator in the chat. Returns a ChatMember object on success.
|
|
type GetChatMemberParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
}
|
|
|
|
// GetChatMember calls the getChatMember Telegram Bot API method.
|
|
//
|
|
// Use this method to get information about a member of a chat. The method is only guaranteed to work for other users if the bot is an administrator in the chat. Returns a ChatMember object on success.
|
|
func GetChatMember(ctx context.Context, b *client.Bot, p *GetChatMemberParams) (ChatMember, error) {
|
|
raw, err := client.CallRaw[*GetChatMemberParams](ctx, b, "getChatMember", p)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return UnmarshalChatMember(raw)
|
|
}
|
|
|
|
// GetUserPersonalChatMessagesParams is the parameter set for GetUserPersonalChatMessages.
|
|
//
|
|
// Use this method to get the last messages from the personal chat (i.e., the chat currently added to their profile) of a given user. On success, an array of Message objects is returned.
|
|
type GetUserPersonalChatMessagesParams struct {
|
|
// Unique identifier for the target user
|
|
UserID int64 `json:"user_id"`
|
|
// The maximum number of messages to return; 1-20
|
|
Limit int64 `json:"limit"`
|
|
}
|
|
|
|
// GetUserPersonalChatMessages calls the getUserPersonalChatMessages Telegram Bot API method.
|
|
//
|
|
// Use this method to get the last messages from the personal chat (i.e., the chat currently added to their profile) of a given user. On success, an array of Message objects is returned.
|
|
func GetUserPersonalChatMessages(ctx context.Context, b *client.Bot, p *GetUserPersonalChatMessagesParams) ([]Message, error) {
|
|
return client.Call[*GetUserPersonalChatMessagesParams, []Message](ctx, b, "getUserPersonalChatMessages", p)
|
|
}
|
|
|
|
// SetChatStickerSetParams is the parameter set for SetChatStickerSet.
|
|
//
|
|
// Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
|
|
type SetChatStickerSetParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Name of the sticker set to be set as the group sticker set
|
|
StickerSetName string `json:"sticker_set_name"`
|
|
}
|
|
|
|
// SetChatStickerSet calls the setChatStickerSet Telegram Bot API method.
|
|
//
|
|
// Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
|
|
func SetChatStickerSet(ctx context.Context, b *client.Bot, p *SetChatStickerSetParams) (bool, error) {
|
|
return client.Call[*SetChatStickerSetParams, bool](ctx, b, "setChatStickerSet", p)
|
|
}
|
|
|
|
// DeleteChatStickerSetParams is the parameter set for DeleteChatStickerSet.
|
|
//
|
|
// Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
|
|
type DeleteChatStickerSetParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// DeleteChatStickerSet calls the deleteChatStickerSet Telegram Bot API method.
|
|
//
|
|
// Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
|
|
func DeleteChatStickerSet(ctx context.Context, b *client.Bot, p *DeleteChatStickerSetParams) (bool, error) {
|
|
return client.Call[*DeleteChatStickerSetParams, bool](ctx, b, "deleteChatStickerSet", p)
|
|
}
|
|
|
|
// GetForumTopicIconStickersParams is the parameter set for GetForumTopicIconStickers.
|
|
//
|
|
// Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of Sticker objects.
|
|
type GetForumTopicIconStickersParams struct {
|
|
}
|
|
|
|
// GetForumTopicIconStickers calls the getForumTopicIconStickers Telegram Bot API method.
|
|
//
|
|
// Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of Sticker objects.
|
|
func GetForumTopicIconStickers(ctx context.Context, b *client.Bot, p *GetForumTopicIconStickersParams) ([]Sticker, error) {
|
|
return client.Call[*GetForumTopicIconStickersParams, []Sticker](ctx, b, "getForumTopicIconStickers", p)
|
|
}
|
|
|
|
// CreateForumTopicParams is the parameter set for CreateForumTopic.
|
|
//
|
|
// Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator right. Returns information about the created topic as a ForumTopic object.
|
|
type CreateForumTopicParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Topic name, 1-128 characters
|
|
Name string `json:"name"`
|
|
// Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F).
|
|
IconColor *int64 `json:"icon_color,omitempty"`
|
|
// Unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.
|
|
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
|
|
}
|
|
|
|
// CreateForumTopic calls the createForumTopic Telegram Bot API method.
|
|
//
|
|
// Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator right. Returns information about the created topic as a ForumTopic object.
|
|
func CreateForumTopic(ctx context.Context, b *client.Bot, p *CreateForumTopicParams) (*ForumTopic, error) {
|
|
return client.Call[*CreateForumTopicParams, *ForumTopic](ctx, b, "createForumTopic", p)
|
|
}
|
|
|
|
// EditForumTopicParams is the parameter set for EditForumTopic.
|
|
//
|
|
// Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
type EditForumTopicParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier for the target message thread of the forum topic
|
|
MessageThreadID int64 `json:"message_thread_id"`
|
|
// New topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept.
|
|
Name string `json:"name,omitempty"`
|
|
// New unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers. Pass an empty string to remove the icon. If not specified, the current icon will be kept.
|
|
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
|
|
}
|
|
|
|
// EditForumTopic calls the editForumTopic Telegram Bot API method.
|
|
//
|
|
// Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
func EditForumTopic(ctx context.Context, b *client.Bot, p *EditForumTopicParams) (bool, error) {
|
|
return client.Call[*EditForumTopicParams, bool](ctx, b, "editForumTopic", p)
|
|
}
|
|
|
|
// CloseForumTopicParams is the parameter set for CloseForumTopic.
|
|
//
|
|
// Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
type CloseForumTopicParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier for the target message thread of the forum topic
|
|
MessageThreadID int64 `json:"message_thread_id"`
|
|
}
|
|
|
|
// CloseForumTopic calls the closeForumTopic Telegram Bot API method.
|
|
//
|
|
// Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
func CloseForumTopic(ctx context.Context, b *client.Bot, p *CloseForumTopicParams) (bool, error) {
|
|
return client.Call[*CloseForumTopicParams, bool](ctx, b, "closeForumTopic", p)
|
|
}
|
|
|
|
// ReopenForumTopicParams is the parameter set for ReopenForumTopic.
|
|
//
|
|
// Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
type ReopenForumTopicParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier for the target message thread of the forum topic
|
|
MessageThreadID int64 `json:"message_thread_id"`
|
|
}
|
|
|
|
// ReopenForumTopic calls the reopenForumTopic Telegram Bot API method.
|
|
//
|
|
// Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
func ReopenForumTopic(ctx context.Context, b *client.Bot, p *ReopenForumTopicParams) (bool, error) {
|
|
return client.Call[*ReopenForumTopicParams, bool](ctx, b, "reopenForumTopic", p)
|
|
}
|
|
|
|
// DeleteForumTopicParams is the parameter set for DeleteForumTopic.
|
|
//
|
|
// Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success.
|
|
type DeleteForumTopicParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier for the target message thread of the forum topic
|
|
MessageThreadID int64 `json:"message_thread_id"`
|
|
}
|
|
|
|
// DeleteForumTopic calls the deleteForumTopic Telegram Bot API method.
|
|
//
|
|
// Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success.
|
|
func DeleteForumTopic(ctx context.Context, b *client.Bot, p *DeleteForumTopicParams) (bool, error) {
|
|
return client.Call[*DeleteForumTopicParams, bool](ctx, b, "deleteForumTopic", p)
|
|
}
|
|
|
|
// UnpinAllForumTopicMessagesParams is the parameter set for UnpinAllForumTopicMessages.
|
|
//
|
|
// Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
|
|
type UnpinAllForumTopicMessagesParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier for the target message thread of the forum topic
|
|
MessageThreadID int64 `json:"message_thread_id"`
|
|
}
|
|
|
|
// UnpinAllForumTopicMessages calls the unpinAllForumTopicMessages Telegram Bot API method.
|
|
//
|
|
// Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
|
|
func UnpinAllForumTopicMessages(ctx context.Context, b *client.Bot, p *UnpinAllForumTopicMessagesParams) (bool, error) {
|
|
return client.Call[*UnpinAllForumTopicMessagesParams, bool](ctx, b, "unpinAllForumTopicMessages", p)
|
|
}
|
|
|
|
// EditGeneralForumTopicParams is the parameter set for EditGeneralForumTopic.
|
|
//
|
|
// Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
type EditGeneralForumTopicParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// New topic name, 1-128 characters
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// EditGeneralForumTopic calls the editGeneralForumTopic Telegram Bot API method.
|
|
//
|
|
// Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
func EditGeneralForumTopic(ctx context.Context, b *client.Bot, p *EditGeneralForumTopicParams) (bool, error) {
|
|
return client.Call[*EditGeneralForumTopicParams, bool](ctx, b, "editGeneralForumTopic", p)
|
|
}
|
|
|
|
// CloseGeneralForumTopicParams is the parameter set for CloseGeneralForumTopic.
|
|
//
|
|
// Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
type CloseGeneralForumTopicParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// CloseGeneralForumTopic calls the closeGeneralForumTopic Telegram Bot API method.
|
|
//
|
|
// Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
func CloseGeneralForumTopic(ctx context.Context, b *client.Bot, p *CloseGeneralForumTopicParams) (bool, error) {
|
|
return client.Call[*CloseGeneralForumTopicParams, bool](ctx, b, "closeGeneralForumTopic", p)
|
|
}
|
|
|
|
// ReopenGeneralForumTopicParams is the parameter set for ReopenGeneralForumTopic.
|
|
//
|
|
// Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success.
|
|
type ReopenGeneralForumTopicParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// ReopenGeneralForumTopic calls the reopenGeneralForumTopic Telegram Bot API method.
|
|
//
|
|
// Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success.
|
|
func ReopenGeneralForumTopic(ctx context.Context, b *client.Bot, p *ReopenGeneralForumTopicParams) (bool, error) {
|
|
return client.Call[*ReopenGeneralForumTopicParams, bool](ctx, b, "reopenGeneralForumTopic", p)
|
|
}
|
|
|
|
// HideGeneralForumTopicParams is the parameter set for HideGeneralForumTopic.
|
|
//
|
|
// Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success.
|
|
type HideGeneralForumTopicParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// HideGeneralForumTopic calls the hideGeneralForumTopic Telegram Bot API method.
|
|
//
|
|
// Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success.
|
|
func HideGeneralForumTopic(ctx context.Context, b *client.Bot, p *HideGeneralForumTopicParams) (bool, error) {
|
|
return client.Call[*HideGeneralForumTopicParams, bool](ctx, b, "hideGeneralForumTopic", p)
|
|
}
|
|
|
|
// UnhideGeneralForumTopicParams is the parameter set for UnhideGeneralForumTopic.
|
|
//
|
|
// Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
type UnhideGeneralForumTopicParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// UnhideGeneralForumTopic calls the unhideGeneralForumTopic Telegram Bot API method.
|
|
//
|
|
// Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
func UnhideGeneralForumTopic(ctx context.Context, b *client.Bot, p *UnhideGeneralForumTopicParams) (bool, error) {
|
|
return client.Call[*UnhideGeneralForumTopicParams, bool](ctx, b, "unhideGeneralForumTopic", p)
|
|
}
|
|
|
|
// UnpinAllGeneralForumTopicMessagesParams is the parameter set for UnpinAllGeneralForumTopicMessages.
|
|
//
|
|
// Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
|
|
type UnpinAllGeneralForumTopicMessagesParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// UnpinAllGeneralForumTopicMessages calls the unpinAllGeneralForumTopicMessages Telegram Bot API method.
|
|
//
|
|
// Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
|
|
func UnpinAllGeneralForumTopicMessages(ctx context.Context, b *client.Bot, p *UnpinAllGeneralForumTopicMessagesParams) (bool, error) {
|
|
return client.Call[*UnpinAllGeneralForumTopicMessagesParams, bool](ctx, b, "unpinAllGeneralForumTopicMessages", p)
|
|
}
|
|
|
|
// AnswerCallbackQueryParams is the parameter set for AnswerCallbackQuery.
|
|
//
|
|
// Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
|
|
// Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
|
|
type AnswerCallbackQueryParams struct {
|
|
// Unique identifier for the query to be answered
|
|
CallbackQueryID string `json:"callback_query_id"`
|
|
// Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.
|
|
Text string `json:"text,omitempty"`
|
|
// If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
|
|
ShowAlert *bool `json:"show_alert,omitempty"`
|
|
// URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @BotFather, specify the URL that opens your game - note that this will only work if the query comes from a callback_game button.Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
|
|
URL string `json:"url,omitempty"`
|
|
// The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
|
|
CacheTime *int64 `json:"cache_time,omitempty"`
|
|
}
|
|
|
|
// AnswerCallbackQuery calls the answerCallbackQuery Telegram Bot API method.
|
|
//
|
|
// Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
|
|
// Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
|
|
func AnswerCallbackQuery(ctx context.Context, b *client.Bot, p *AnswerCallbackQueryParams) (bool, error) {
|
|
return client.Call[*AnswerCallbackQueryParams, bool](ctx, b, "answerCallbackQuery", p)
|
|
}
|
|
|
|
// AnswerGuestQueryParams is the parameter set for AnswerGuestQuery.
|
|
//
|
|
// Use this method to reply to a received guest message. On success, a SentGuestMessage object is returned.
|
|
type AnswerGuestQueryParams struct {
|
|
// Unique identifier for the query to be answered
|
|
GuestQueryID string `json:"guest_query_id"`
|
|
// A JSON-serialized object describing the message to be sent
|
|
Result InlineQueryResult `json:"result"`
|
|
}
|
|
|
|
// AnswerGuestQuery calls the answerGuestQuery Telegram Bot API method.
|
|
//
|
|
// Use this method to reply to a received guest message. On success, a SentGuestMessage object is returned.
|
|
func AnswerGuestQuery(ctx context.Context, b *client.Bot, p *AnswerGuestQueryParams) (*SentGuestMessage, error) {
|
|
return client.Call[*AnswerGuestQueryParams, *SentGuestMessage](ctx, b, "answerGuestQuery", p)
|
|
}
|
|
|
|
// GetUserChatBoostsParams is the parameter set for GetUserChatBoosts.
|
|
//
|
|
// Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object.
|
|
type GetUserChatBoostsParams struct {
|
|
// Unique identifier for the chat or username of the channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
}
|
|
|
|
// GetUserChatBoosts calls the getUserChatBoosts Telegram Bot API method.
|
|
//
|
|
// Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object.
|
|
func GetUserChatBoosts(ctx context.Context, b *client.Bot, p *GetUserChatBoostsParams) (*UserChatBoosts, error) {
|
|
return client.Call[*GetUserChatBoostsParams, *UserChatBoosts](ctx, b, "getUserChatBoosts", p)
|
|
}
|
|
|
|
// GetBusinessConnectionParams is the parameter set for GetBusinessConnection.
|
|
//
|
|
// Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
|
|
type GetBusinessConnectionParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
}
|
|
|
|
// GetBusinessConnection calls the getBusinessConnection Telegram Bot API method.
|
|
//
|
|
// Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
|
|
func GetBusinessConnection(ctx context.Context, b *client.Bot, p *GetBusinessConnectionParams) (*BusinessConnection, error) {
|
|
return client.Call[*GetBusinessConnectionParams, *BusinessConnection](ctx, b, "getBusinessConnection", p)
|
|
}
|
|
|
|
// GetManagedBotTokenParams is the parameter set for GetManagedBotToken.
|
|
//
|
|
// Use this method to get the token of a managed bot. Returns the token as String on success.
|
|
type GetManagedBotTokenParams struct {
|
|
// User identifier of the managed bot whose token will be returned
|
|
UserID int64 `json:"user_id"`
|
|
}
|
|
|
|
// GetManagedBotToken calls the getManagedBotToken Telegram Bot API method.
|
|
//
|
|
// Use this method to get the token of a managed bot. Returns the token as String on success.
|
|
func GetManagedBotToken(ctx context.Context, b *client.Bot, p *GetManagedBotTokenParams) (string, error) {
|
|
return client.Call[*GetManagedBotTokenParams, string](ctx, b, "getManagedBotToken", p)
|
|
}
|
|
|
|
// ReplaceManagedBotTokenParams is the parameter set for ReplaceManagedBotToken.
|
|
//
|
|
// Use this method to revoke the current token of a managed bot and generate a new one. Returns the new token as String on success.
|
|
type ReplaceManagedBotTokenParams struct {
|
|
// User identifier of the managed bot whose token will be replaced
|
|
UserID int64 `json:"user_id"`
|
|
}
|
|
|
|
// ReplaceManagedBotToken calls the replaceManagedBotToken Telegram Bot API method.
|
|
//
|
|
// Use this method to revoke the current token of a managed bot and generate a new one. Returns the new token as String on success.
|
|
func ReplaceManagedBotToken(ctx context.Context, b *client.Bot, p *ReplaceManagedBotTokenParams) (string, error) {
|
|
return client.Call[*ReplaceManagedBotTokenParams, string](ctx, b, "replaceManagedBotToken", p)
|
|
}
|
|
|
|
// GetManagedBotAccessSettingsParams is the parameter set for GetManagedBotAccessSettings.
|
|
//
|
|
// Use this method to get the access settings of a managed bot. Returns a BotAccessSettings object on success.
|
|
type GetManagedBotAccessSettingsParams struct {
|
|
// User identifier of the managed bot whose access settings will be returned
|
|
UserID int64 `json:"user_id"`
|
|
}
|
|
|
|
// GetManagedBotAccessSettings calls the getManagedBotAccessSettings Telegram Bot API method.
|
|
//
|
|
// Use this method to get the access settings of a managed bot. Returns a BotAccessSettings object on success.
|
|
func GetManagedBotAccessSettings(ctx context.Context, b *client.Bot, p *GetManagedBotAccessSettingsParams) (*BotAccessSettings, error) {
|
|
return client.Call[*GetManagedBotAccessSettingsParams, *BotAccessSettings](ctx, b, "getManagedBotAccessSettings", p)
|
|
}
|
|
|
|
// SetManagedBotAccessSettingsParams is the parameter set for SetManagedBotAccessSettings.
|
|
//
|
|
// Use this method to change the access settings of a managed bot. Returns True on success.
|
|
type SetManagedBotAccessSettingsParams struct {
|
|
// User identifier of the managed bot whose access settings will be changed
|
|
UserID int64 `json:"user_id"`
|
|
// Pass True, if only selected users can access the bot. The bot's owner can always access it.
|
|
IsAccessRestricted bool `json:"is_access_restricted"`
|
|
// A JSON-serialized list of up to 10 identifiers of users who will have access to the bot in addition to its owner. Ignored if is_access_restricted is false.
|
|
AddedUserIds []int64 `json:"added_user_ids,omitempty"`
|
|
}
|
|
|
|
// SetManagedBotAccessSettings calls the setManagedBotAccessSettings Telegram Bot API method.
|
|
//
|
|
// Use this method to change the access settings of a managed bot. Returns True on success.
|
|
func SetManagedBotAccessSettings(ctx context.Context, b *client.Bot, p *SetManagedBotAccessSettingsParams) (bool, error) {
|
|
return client.Call[*SetManagedBotAccessSettingsParams, bool](ctx, b, "setManagedBotAccessSettings", p)
|
|
}
|
|
|
|
// SetMyCommandsParams is the parameter set for SetMyCommands.
|
|
//
|
|
// Use this method to change the list of the bot's commands. See this manual for more details about bot commands. Returns True on success.
|
|
type SetMyCommandsParams struct {
|
|
// A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
|
|
Commands []BotCommand `json:"commands"`
|
|
// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
|
|
Scope BotCommandScope `json:"scope,omitempty"`
|
|
// A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands.
|
|
LanguageCode string `json:"language_code,omitempty"`
|
|
}
|
|
|
|
// SetMyCommands calls the setMyCommands Telegram Bot API method.
|
|
//
|
|
// Use this method to change the list of the bot's commands. See this manual for more details about bot commands. Returns True on success.
|
|
func SetMyCommands(ctx context.Context, b *client.Bot, p *SetMyCommandsParams) (bool, error) {
|
|
return client.Call[*SetMyCommandsParams, bool](ctx, b, "setMyCommands", p)
|
|
}
|
|
|
|
// DeleteMyCommandsParams is the parameter set for DeleteMyCommands.
|
|
//
|
|
// Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success.
|
|
type DeleteMyCommandsParams struct {
|
|
// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
|
|
Scope BotCommandScope `json:"scope,omitempty"`
|
|
// A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands.
|
|
LanguageCode string `json:"language_code,omitempty"`
|
|
}
|
|
|
|
// DeleteMyCommands calls the deleteMyCommands Telegram Bot API method.
|
|
//
|
|
// Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success.
|
|
func DeleteMyCommands(ctx context.Context, b *client.Bot, p *DeleteMyCommandsParams) (bool, error) {
|
|
return client.Call[*DeleteMyCommandsParams, bool](ctx, b, "deleteMyCommands", p)
|
|
}
|
|
|
|
// GetMyCommandsParams is the parameter set for GetMyCommands.
|
|
//
|
|
// Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of BotCommand objects. If commands aren't set, an empty list is returned.
|
|
type GetMyCommandsParams struct {
|
|
// A JSON-serialized object, describing scope of users. Defaults to BotCommandScopeDefault.
|
|
Scope BotCommandScope `json:"scope,omitempty"`
|
|
// A two-letter ISO 639-1 language code or an empty string
|
|
LanguageCode string `json:"language_code,omitempty"`
|
|
}
|
|
|
|
// GetMyCommands calls the getMyCommands Telegram Bot API method.
|
|
//
|
|
// Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of BotCommand objects. If commands aren't set, an empty list is returned.
|
|
func GetMyCommands(ctx context.Context, b *client.Bot, p *GetMyCommandsParams) ([]BotCommand, error) {
|
|
return client.Call[*GetMyCommandsParams, []BotCommand](ctx, b, "getMyCommands", p)
|
|
}
|
|
|
|
// SetMyNameParams is the parameter set for SetMyName.
|
|
//
|
|
// Use this method to change the bot's name. Returns True on success.
|
|
type SetMyNameParams struct {
|
|
// New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
|
|
Name string `json:"name,omitempty"`
|
|
// A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
|
|
LanguageCode string `json:"language_code,omitempty"`
|
|
}
|
|
|
|
// SetMyName calls the setMyName Telegram Bot API method.
|
|
//
|
|
// Use this method to change the bot's name. Returns True on success.
|
|
func SetMyName(ctx context.Context, b *client.Bot, p *SetMyNameParams) (bool, error) {
|
|
return client.Call[*SetMyNameParams, bool](ctx, b, "setMyName", p)
|
|
}
|
|
|
|
// GetMyNameParams is the parameter set for GetMyName.
|
|
//
|
|
// Use this method to get the current bot name for the given user language. Returns BotName on success.
|
|
type GetMyNameParams struct {
|
|
// A two-letter ISO 639-1 language code or an empty string
|
|
LanguageCode string `json:"language_code,omitempty"`
|
|
}
|
|
|
|
// GetMyName calls the getMyName Telegram Bot API method.
|
|
//
|
|
// Use this method to get the current bot name for the given user language. Returns BotName on success.
|
|
func GetMyName(ctx context.Context, b *client.Bot, p *GetMyNameParams) (*BotName, error) {
|
|
return client.Call[*GetMyNameParams, *BotName](ctx, b, "getMyName", p)
|
|
}
|
|
|
|
// SetMyDescriptionParams is the parameter set for SetMyDescription.
|
|
//
|
|
// Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success.
|
|
type SetMyDescriptionParams struct {
|
|
// New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
|
|
Description string `json:"description,omitempty"`
|
|
// A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.
|
|
LanguageCode string `json:"language_code,omitempty"`
|
|
}
|
|
|
|
// SetMyDescription calls the setMyDescription Telegram Bot API method.
|
|
//
|
|
// Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success.
|
|
func SetMyDescription(ctx context.Context, b *client.Bot, p *SetMyDescriptionParams) (bool, error) {
|
|
return client.Call[*SetMyDescriptionParams, bool](ctx, b, "setMyDescription", p)
|
|
}
|
|
|
|
// GetMyDescriptionParams is the parameter set for GetMyDescription.
|
|
//
|
|
// Use this method to get the current bot description for the given user language. Returns BotDescription on success.
|
|
type GetMyDescriptionParams struct {
|
|
// A two-letter ISO 639-1 language code or an empty string
|
|
LanguageCode string `json:"language_code,omitempty"`
|
|
}
|
|
|
|
// GetMyDescription calls the getMyDescription Telegram Bot API method.
|
|
//
|
|
// Use this method to get the current bot description for the given user language. Returns BotDescription on success.
|
|
func GetMyDescription(ctx context.Context, b *client.Bot, p *GetMyDescriptionParams) (*BotDescription, error) {
|
|
return client.Call[*GetMyDescriptionParams, *BotDescription](ctx, b, "getMyDescription", p)
|
|
}
|
|
|
|
// SetMyShortDescriptionParams is the parameter set for SetMyShortDescription.
|
|
//
|
|
// Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success.
|
|
type SetMyShortDescriptionParams struct {
|
|
// New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.
|
|
ShortDescription string `json:"short_description,omitempty"`
|
|
// A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.
|
|
LanguageCode string `json:"language_code,omitempty"`
|
|
}
|
|
|
|
// SetMyShortDescription calls the setMyShortDescription Telegram Bot API method.
|
|
//
|
|
// Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success.
|
|
func SetMyShortDescription(ctx context.Context, b *client.Bot, p *SetMyShortDescriptionParams) (bool, error) {
|
|
return client.Call[*SetMyShortDescriptionParams, bool](ctx, b, "setMyShortDescription", p)
|
|
}
|
|
|
|
// GetMyShortDescriptionParams is the parameter set for GetMyShortDescription.
|
|
//
|
|
// Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success.
|
|
type GetMyShortDescriptionParams struct {
|
|
// A two-letter ISO 639-1 language code or an empty string
|
|
LanguageCode string `json:"language_code,omitempty"`
|
|
}
|
|
|
|
// GetMyShortDescription calls the getMyShortDescription Telegram Bot API method.
|
|
//
|
|
// Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success.
|
|
func GetMyShortDescription(ctx context.Context, b *client.Bot, p *GetMyShortDescriptionParams) (*BotShortDescription, error) {
|
|
return client.Call[*GetMyShortDescriptionParams, *BotShortDescription](ctx, b, "getMyShortDescription", p)
|
|
}
|
|
|
|
// SetMyProfilePhotoParams is the parameter set for SetMyProfilePhoto.
|
|
//
|
|
// Changes the profile photo of the bot. Returns True on success.
|
|
type SetMyProfilePhotoParams struct {
|
|
// The new profile photo to set
|
|
Photo InputProfilePhoto `json:"photo"`
|
|
}
|
|
|
|
// SetMyProfilePhoto calls the setMyProfilePhoto Telegram Bot API method.
|
|
//
|
|
// Changes the profile photo of the bot. Returns True on success.
|
|
func SetMyProfilePhoto(ctx context.Context, b *client.Bot, p *SetMyProfilePhotoParams) (bool, error) {
|
|
return client.Call[*SetMyProfilePhotoParams, bool](ctx, b, "setMyProfilePhoto", p)
|
|
}
|
|
|
|
// RemoveMyProfilePhotoParams is the parameter set for RemoveMyProfilePhoto.
|
|
//
|
|
// Removes the profile photo of the bot. Requires no parameters. Returns True on success.
|
|
type RemoveMyProfilePhotoParams struct {
|
|
}
|
|
|
|
// RemoveMyProfilePhoto calls the removeMyProfilePhoto Telegram Bot API method.
|
|
//
|
|
// Removes the profile photo of the bot. Requires no parameters. Returns True on success.
|
|
func RemoveMyProfilePhoto(ctx context.Context, b *client.Bot, p *RemoveMyProfilePhotoParams) (bool, error) {
|
|
return client.Call[*RemoveMyProfilePhotoParams, bool](ctx, b, "removeMyProfilePhoto", p)
|
|
}
|
|
|
|
// SetChatMenuButtonParams is the parameter set for SetChatMenuButton.
|
|
//
|
|
// Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.
|
|
type SetChatMenuButtonParams struct {
|
|
// Unique identifier for the target private chat. If not specified, the bot's default menu button will be changed.
|
|
ChatID *int64 `json:"chat_id,omitempty"`
|
|
// A JSON-serialized object for the bot's new menu button. Defaults to MenuButtonDefault.
|
|
MenuButton MenuButton `json:"menu_button,omitempty"`
|
|
}
|
|
|
|
// SetChatMenuButton calls the setChatMenuButton Telegram Bot API method.
|
|
//
|
|
// Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.
|
|
func SetChatMenuButton(ctx context.Context, b *client.Bot, p *SetChatMenuButtonParams) (bool, error) {
|
|
return client.Call[*SetChatMenuButtonParams, bool](ctx, b, "setChatMenuButton", p)
|
|
}
|
|
|
|
// GetChatMenuButtonParams is the parameter set for GetChatMenuButton.
|
|
//
|
|
// Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success.
|
|
type GetChatMenuButtonParams struct {
|
|
// Unique identifier for the target private chat. If not specified, the bot's default menu button will be returned.
|
|
ChatID *int64 `json:"chat_id,omitempty"`
|
|
}
|
|
|
|
// GetChatMenuButton calls the getChatMenuButton Telegram Bot API method.
|
|
//
|
|
// Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success.
|
|
func GetChatMenuButton(ctx context.Context, b *client.Bot, p *GetChatMenuButtonParams) (MenuButton, error) {
|
|
raw, err := client.CallRaw[*GetChatMenuButtonParams](ctx, b, "getChatMenuButton", p)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return UnmarshalMenuButton(raw)
|
|
}
|
|
|
|
// SetMyDefaultAdministratorRightsParams is the parameter set for SetMyDefaultAdministratorRights.
|
|
//
|
|
// Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns True on success.
|
|
type SetMyDefaultAdministratorRightsParams struct {
|
|
// A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared.
|
|
Rights *ChatAdministratorRights `json:"rights,omitempty"`
|
|
// Pass True to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.
|
|
ForChannels *bool `json:"for_channels,omitempty"`
|
|
}
|
|
|
|
// SetMyDefaultAdministratorRights calls the setMyDefaultAdministratorRights Telegram Bot API method.
|
|
//
|
|
// Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns True on success.
|
|
func SetMyDefaultAdministratorRights(ctx context.Context, b *client.Bot, p *SetMyDefaultAdministratorRightsParams) (bool, error) {
|
|
return client.Call[*SetMyDefaultAdministratorRightsParams, bool](ctx, b, "setMyDefaultAdministratorRights", p)
|
|
}
|
|
|
|
// GetMyDefaultAdministratorRightsParams is the parameter set for GetMyDefaultAdministratorRights.
|
|
//
|
|
// Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
|
|
type GetMyDefaultAdministratorRightsParams struct {
|
|
// Pass True to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.
|
|
ForChannels *bool `json:"for_channels,omitempty"`
|
|
}
|
|
|
|
// GetMyDefaultAdministratorRights calls the getMyDefaultAdministratorRights Telegram Bot API method.
|
|
//
|
|
// Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
|
|
func GetMyDefaultAdministratorRights(ctx context.Context, b *client.Bot, p *GetMyDefaultAdministratorRightsParams) (*ChatAdministratorRights, error) {
|
|
return client.Call[*GetMyDefaultAdministratorRightsParams, *ChatAdministratorRights](ctx, b, "getMyDefaultAdministratorRights", p)
|
|
}
|
|
|
|
// GetAvailableGiftsParams is the parameter set for GetAvailableGifts.
|
|
//
|
|
// Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a Gifts object.
|
|
type GetAvailableGiftsParams struct {
|
|
}
|
|
|
|
// GetAvailableGifts calls the getAvailableGifts Telegram Bot API method.
|
|
//
|
|
// Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a Gifts object.
|
|
func GetAvailableGifts(ctx context.Context, b *client.Bot, p *GetAvailableGiftsParams) (*Gifts, error) {
|
|
return client.Call[*GetAvailableGiftsParams, *Gifts](ctx, b, "getAvailableGifts", p)
|
|
}
|
|
|
|
// SendGiftParams is the parameter set for SendGift.
|
|
//
|
|
// Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success.
|
|
type SendGiftParams struct {
|
|
// Required if chat_id is not specified. Unique identifier of the target user who will receive the gift.
|
|
UserID *int64 `json:"user_id,omitempty"`
|
|
// Required if user_id is not specified. Unique identifier for the chat or username of the channel (in the format @username) that will receive the gift.
|
|
ChatID *ChatID `json:"chat_id,omitempty"`
|
|
// Identifier of the gift; limited gifts can't be sent to channel chats
|
|
GiftID string `json:"gift_id"`
|
|
// Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver
|
|
PayForUpgrade *bool `json:"pay_for_upgrade,omitempty"`
|
|
// Text that will be shown along with the gift; 0-128 characters
|
|
Text string `json:"text,omitempty"`
|
|
// Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, “custom_emoji”, and “date_time” are ignored.
|
|
TextParseMode ParseMode `json:"text_parse_mode,omitempty"`
|
|
// A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, “custom_emoji”, and “date_time” are ignored.
|
|
TextEntities []MessageEntity `json:"text_entities,omitempty"`
|
|
}
|
|
|
|
// SendGift calls the sendGift Telegram Bot API method.
|
|
//
|
|
// Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success.
|
|
func SendGift(ctx context.Context, b *client.Bot, p *SendGiftParams) (bool, error) {
|
|
return client.Call[*SendGiftParams, bool](ctx, b, "sendGift", p)
|
|
}
|
|
|
|
// GiftPremiumSubscriptionParams is the parameter set for GiftPremiumSubscription.
|
|
//
|
|
// Gifts a Telegram Premium subscription to the given user. Returns True on success.
|
|
type GiftPremiumSubscriptionParams struct {
|
|
// Unique identifier of the target user who will receive a Telegram Premium subscription
|
|
UserID int64 `json:"user_id"`
|
|
// Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12
|
|
MonthCount int64 `json:"month_count"`
|
|
// Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months
|
|
StarCount int64 `json:"star_count"`
|
|
// Text that will be shown along with the service message about the subscription; 0-128 characters
|
|
Text string `json:"text,omitempty"`
|
|
// Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, “custom_emoji”, and “date_time” are ignored.
|
|
TextParseMode ParseMode `json:"text_parse_mode,omitempty"`
|
|
// A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, “custom_emoji”, and “date_time” are ignored.
|
|
TextEntities []MessageEntity `json:"text_entities,omitempty"`
|
|
}
|
|
|
|
// GiftPremiumSubscription calls the giftPremiumSubscription Telegram Bot API method.
|
|
//
|
|
// Gifts a Telegram Premium subscription to the given user. Returns True on success.
|
|
func GiftPremiumSubscription(ctx context.Context, b *client.Bot, p *GiftPremiumSubscriptionParams) (bool, error) {
|
|
return client.Call[*GiftPremiumSubscriptionParams, bool](ctx, b, "giftPremiumSubscription", p)
|
|
}
|
|
|
|
// VerifyUserParams is the parameter set for VerifyUser.
|
|
//
|
|
// Verifies a user on behalf of the organization which is represented by the bot. Returns True on success.
|
|
type VerifyUserParams struct {
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
// Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description.
|
|
CustomDescription string `json:"custom_description,omitempty"`
|
|
}
|
|
|
|
// VerifyUser calls the verifyUser Telegram Bot API method.
|
|
//
|
|
// Verifies a user on behalf of the organization which is represented by the bot. Returns True on success.
|
|
func VerifyUser(ctx context.Context, b *client.Bot, p *VerifyUserParams) (bool, error) {
|
|
return client.Call[*VerifyUserParams, bool](ctx, b, "verifyUser", p)
|
|
}
|
|
|
|
// VerifyChatParams is the parameter set for VerifyChat.
|
|
//
|
|
// Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success.
|
|
type VerifyChatParams struct {
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username. Channel direct messages chats can't be verified.
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description.
|
|
CustomDescription string `json:"custom_description,omitempty"`
|
|
}
|
|
|
|
// VerifyChat calls the verifyChat Telegram Bot API method.
|
|
//
|
|
// Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success.
|
|
func VerifyChat(ctx context.Context, b *client.Bot, p *VerifyChatParams) (bool, error) {
|
|
return client.Call[*VerifyChatParams, bool](ctx, b, "verifyChat", p)
|
|
}
|
|
|
|
// RemoveUserVerificationParams is the parameter set for RemoveUserVerification.
|
|
//
|
|
// Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success.
|
|
type RemoveUserVerificationParams struct {
|
|
// Unique identifier of the target user
|
|
UserID int64 `json:"user_id"`
|
|
}
|
|
|
|
// RemoveUserVerification calls the removeUserVerification Telegram Bot API method.
|
|
//
|
|
// Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success.
|
|
func RemoveUserVerification(ctx context.Context, b *client.Bot, p *RemoveUserVerificationParams) (bool, error) {
|
|
return client.Call[*RemoveUserVerificationParams, bool](ctx, b, "removeUserVerification", p)
|
|
}
|
|
|
|
// RemoveChatVerificationParams is the parameter set for RemoveChatVerification.
|
|
//
|
|
// Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success.
|
|
type RemoveChatVerificationParams struct {
|
|
// Unique identifier for the target chat or username of the target bot or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
}
|
|
|
|
// RemoveChatVerification calls the removeChatVerification Telegram Bot API method.
|
|
//
|
|
// Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success.
|
|
func RemoveChatVerification(ctx context.Context, b *client.Bot, p *RemoveChatVerificationParams) (bool, error) {
|
|
return client.Call[*RemoveChatVerificationParams, bool](ctx, b, "removeChatVerification", p)
|
|
}
|
|
|
|
// ReadBusinessMessageParams is the parameter set for ReadBusinessMessage.
|
|
//
|
|
// Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success.
|
|
type ReadBusinessMessageParams struct {
|
|
// Unique identifier of the business connection on behalf of which to read the message
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours.
|
|
ChatID int64 `json:"chat_id"`
|
|
// Unique identifier of the message to mark as read
|
|
MessageID int64 `json:"message_id"`
|
|
}
|
|
|
|
// ReadBusinessMessage calls the readBusinessMessage Telegram Bot API method.
|
|
//
|
|
// Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success.
|
|
func ReadBusinessMessage(ctx context.Context, b *client.Bot, p *ReadBusinessMessageParams) (bool, error) {
|
|
return client.Call[*ReadBusinessMessageParams, bool](ctx, b, "readBusinessMessage", p)
|
|
}
|
|
|
|
// DeleteBusinessMessagesParams is the parameter set for DeleteBusinessMessages.
|
|
//
|
|
// Delete messages on behalf of a business account. Requires the can_delete_sent_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success.
|
|
type DeleteBusinessMessagesParams struct {
|
|
// Unique identifier of the business connection on behalf of which to delete the messages
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// A JSON-serialized list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted.
|
|
MessageIds []int64 `json:"message_ids"`
|
|
}
|
|
|
|
// DeleteBusinessMessages calls the deleteBusinessMessages Telegram Bot API method.
|
|
//
|
|
// Delete messages on behalf of a business account. Requires the can_delete_sent_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success.
|
|
func DeleteBusinessMessages(ctx context.Context, b *client.Bot, p *DeleteBusinessMessagesParams) (bool, error) {
|
|
return client.Call[*DeleteBusinessMessagesParams, bool](ctx, b, "deleteBusinessMessages", p)
|
|
}
|
|
|
|
// SetBusinessAccountNameParams is the parameter set for SetBusinessAccountName.
|
|
//
|
|
// Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success.
|
|
type SetBusinessAccountNameParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// The new value of the first name for the business account; 1-64 characters
|
|
FirstName string `json:"first_name"`
|
|
// The new value of the last name for the business account; 0-64 characters
|
|
LastName string `json:"last_name,omitempty"`
|
|
}
|
|
|
|
// SetBusinessAccountName calls the setBusinessAccountName Telegram Bot API method.
|
|
//
|
|
// Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success.
|
|
func SetBusinessAccountName(ctx context.Context, b *client.Bot, p *SetBusinessAccountNameParams) (bool, error) {
|
|
return client.Call[*SetBusinessAccountNameParams, bool](ctx, b, "setBusinessAccountName", p)
|
|
}
|
|
|
|
// SetBusinessAccountUsernameParams is the parameter set for SetBusinessAccountUsername.
|
|
//
|
|
// Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success.
|
|
type SetBusinessAccountUsernameParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// The new value of the username for the business account; 0-32 characters
|
|
Username string `json:"username,omitempty"`
|
|
}
|
|
|
|
// SetBusinessAccountUsername calls the setBusinessAccountUsername Telegram Bot API method.
|
|
//
|
|
// Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success.
|
|
func SetBusinessAccountUsername(ctx context.Context, b *client.Bot, p *SetBusinessAccountUsernameParams) (bool, error) {
|
|
return client.Call[*SetBusinessAccountUsernameParams, bool](ctx, b, "setBusinessAccountUsername", p)
|
|
}
|
|
|
|
// SetBusinessAccountBioParams is the parameter set for SetBusinessAccountBio.
|
|
//
|
|
// Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success.
|
|
type SetBusinessAccountBioParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// The new value of the bio for the business account; 0-140 characters
|
|
Bio string `json:"bio,omitempty"`
|
|
}
|
|
|
|
// SetBusinessAccountBio calls the setBusinessAccountBio Telegram Bot API method.
|
|
//
|
|
// Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success.
|
|
func SetBusinessAccountBio(ctx context.Context, b *client.Bot, p *SetBusinessAccountBioParams) (bool, error) {
|
|
return client.Call[*SetBusinessAccountBioParams, bool](ctx, b, "setBusinessAccountBio", p)
|
|
}
|
|
|
|
// SetBusinessAccountProfilePhotoParams is the parameter set for SetBusinessAccountProfilePhoto.
|
|
//
|
|
// Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success.
|
|
type SetBusinessAccountProfilePhotoParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// The new profile photo to set
|
|
Photo InputProfilePhoto `json:"photo"`
|
|
// Pass True to set the public photo, which will be visible even if the main photo is hidden by the business account's privacy settings. An account can have only one public photo.
|
|
IsPublic *bool `json:"is_public,omitempty"`
|
|
}
|
|
|
|
// SetBusinessAccountProfilePhoto calls the setBusinessAccountProfilePhoto Telegram Bot API method.
|
|
//
|
|
// Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success.
|
|
func SetBusinessAccountProfilePhoto(ctx context.Context, b *client.Bot, p *SetBusinessAccountProfilePhotoParams) (bool, error) {
|
|
return client.Call[*SetBusinessAccountProfilePhotoParams, bool](ctx, b, "setBusinessAccountProfilePhoto", p)
|
|
}
|
|
|
|
// RemoveBusinessAccountProfilePhotoParams is the parameter set for RemoveBusinessAccountProfilePhoto.
|
|
//
|
|
// Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success.
|
|
type RemoveBusinessAccountProfilePhotoParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Pass True to remove the public photo, which is visible even if the main photo is hidden by the business account's privacy settings. After the main photo is removed, the previous profile photo (if present) becomes the main photo.
|
|
IsPublic *bool `json:"is_public,omitempty"`
|
|
}
|
|
|
|
// RemoveBusinessAccountProfilePhoto calls the removeBusinessAccountProfilePhoto Telegram Bot API method.
|
|
//
|
|
// Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success.
|
|
func RemoveBusinessAccountProfilePhoto(ctx context.Context, b *client.Bot, p *RemoveBusinessAccountProfilePhotoParams) (bool, error) {
|
|
return client.Call[*RemoveBusinessAccountProfilePhotoParams, bool](ctx, b, "removeBusinessAccountProfilePhoto", p)
|
|
}
|
|
|
|
// SetBusinessAccountGiftSettingsParams is the parameter set for SetBusinessAccountGiftSettings.
|
|
//
|
|
// Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the can_change_gift_settings business bot right. Returns True on success.
|
|
type SetBusinessAccountGiftSettingsParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Pass True, if a button for sending a gift to the user or by the business account must always be shown in the input field
|
|
ShowGiftButton bool `json:"show_gift_button"`
|
|
// Types of gifts accepted by the business account
|
|
AcceptedGiftTypes AcceptedGiftTypes `json:"accepted_gift_types"`
|
|
}
|
|
|
|
// SetBusinessAccountGiftSettings calls the setBusinessAccountGiftSettings Telegram Bot API method.
|
|
//
|
|
// Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the can_change_gift_settings business bot right. Returns True on success.
|
|
func SetBusinessAccountGiftSettings(ctx context.Context, b *client.Bot, p *SetBusinessAccountGiftSettingsParams) (bool, error) {
|
|
return client.Call[*SetBusinessAccountGiftSettingsParams, bool](ctx, b, "setBusinessAccountGiftSettings", p)
|
|
}
|
|
|
|
// GetBusinessAccountStarBalanceParams is the parameter set for GetBusinessAccountStarBalance.
|
|
//
|
|
// Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success.
|
|
type GetBusinessAccountStarBalanceParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
}
|
|
|
|
// GetBusinessAccountStarBalance calls the getBusinessAccountStarBalance Telegram Bot API method.
|
|
//
|
|
// Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success.
|
|
func GetBusinessAccountStarBalance(ctx context.Context, b *client.Bot, p *GetBusinessAccountStarBalanceParams) (*StarAmount, error) {
|
|
return client.Call[*GetBusinessAccountStarBalanceParams, *StarAmount](ctx, b, "getBusinessAccountStarBalance", p)
|
|
}
|
|
|
|
// TransferBusinessAccountStarsParams is the parameter set for TransferBusinessAccountStars.
|
|
//
|
|
// Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success.
|
|
type TransferBusinessAccountStarsParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Number of Telegram Stars to transfer; 1-10000
|
|
StarCount int64 `json:"star_count"`
|
|
}
|
|
|
|
// TransferBusinessAccountStars calls the transferBusinessAccountStars Telegram Bot API method.
|
|
//
|
|
// Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success.
|
|
func TransferBusinessAccountStars(ctx context.Context, b *client.Bot, p *TransferBusinessAccountStarsParams) (bool, error) {
|
|
return client.Call[*TransferBusinessAccountStarsParams, bool](ctx, b, "transferBusinessAccountStars", p)
|
|
}
|
|
|
|
// GetBusinessAccountGiftsParams is the parameter set for GetBusinessAccountGifts.
|
|
//
|
|
// Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success.
|
|
type GetBusinessAccountGiftsParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Pass True to exclude gifts that aren't saved to the account's profile page
|
|
ExcludeUnsaved *bool `json:"exclude_unsaved,omitempty"`
|
|
// Pass True to exclude gifts that are saved to the account's profile page
|
|
ExcludeSaved *bool `json:"exclude_saved,omitempty"`
|
|
// Pass True to exclude gifts that can be purchased an unlimited number of times
|
|
ExcludeUnlimited *bool `json:"exclude_unlimited,omitempty"`
|
|
// Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique
|
|
ExcludeLimitedUpgradable *bool `json:"exclude_limited_upgradable,omitempty"`
|
|
// Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique
|
|
ExcludeLimitedNonUpgradable *bool `json:"exclude_limited_non_upgradable,omitempty"`
|
|
// Pass True to exclude unique gifts
|
|
ExcludeUnique *bool `json:"exclude_unique,omitempty"`
|
|
// Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram
|
|
ExcludeFromBlockchain *bool `json:"exclude_from_blockchain,omitempty"`
|
|
// Pass True to sort results by gift price instead of send date. Sorting is applied before pagination.
|
|
SortByPrice *bool `json:"sort_by_price,omitempty"`
|
|
// Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
|
|
Offset string `json:"offset,omitempty"`
|
|
// The maximum number of gifts to be returned; 1-100. Defaults to 100.
|
|
Limit *int64 `json:"limit,omitempty"`
|
|
}
|
|
|
|
// GetBusinessAccountGifts calls the getBusinessAccountGifts Telegram Bot API method.
|
|
//
|
|
// Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success.
|
|
func GetBusinessAccountGifts(ctx context.Context, b *client.Bot, p *GetBusinessAccountGiftsParams) (*OwnedGifts, error) {
|
|
return client.Call[*GetBusinessAccountGiftsParams, *OwnedGifts](ctx, b, "getBusinessAccountGifts", p)
|
|
}
|
|
|
|
// GetUserGiftsParams is the parameter set for GetUserGifts.
|
|
//
|
|
// Returns the gifts owned and hosted by a user. Returns OwnedGifts on success.
|
|
type GetUserGiftsParams struct {
|
|
// Unique identifier of the user
|
|
UserID int64 `json:"user_id"`
|
|
// Pass True to exclude gifts that can be purchased an unlimited number of times
|
|
ExcludeUnlimited *bool `json:"exclude_unlimited,omitempty"`
|
|
// Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique
|
|
ExcludeLimitedUpgradable *bool `json:"exclude_limited_upgradable,omitempty"`
|
|
// Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique
|
|
ExcludeLimitedNonUpgradable *bool `json:"exclude_limited_non_upgradable,omitempty"`
|
|
// Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram
|
|
ExcludeFromBlockchain *bool `json:"exclude_from_blockchain,omitempty"`
|
|
// Pass True to exclude unique gifts
|
|
ExcludeUnique *bool `json:"exclude_unique,omitempty"`
|
|
// Pass True to sort results by gift price instead of send date. Sorting is applied before pagination.
|
|
SortByPrice *bool `json:"sort_by_price,omitempty"`
|
|
// Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results
|
|
Offset string `json:"offset,omitempty"`
|
|
// The maximum number of gifts to be returned; 1-100. Defaults to 100.
|
|
Limit *int64 `json:"limit,omitempty"`
|
|
}
|
|
|
|
// GetUserGifts calls the getUserGifts Telegram Bot API method.
|
|
//
|
|
// Returns the gifts owned and hosted by a user. Returns OwnedGifts on success.
|
|
func GetUserGifts(ctx context.Context, b *client.Bot, p *GetUserGiftsParams) (*OwnedGifts, error) {
|
|
return client.Call[*GetUserGiftsParams, *OwnedGifts](ctx, b, "getUserGifts", p)
|
|
}
|
|
|
|
// GetChatGiftsParams is the parameter set for GetChatGifts.
|
|
//
|
|
// Returns the gifts owned by a chat. Returns OwnedGifts on success.
|
|
type GetChatGiftsParams struct {
|
|
// Unique identifier for the target chat or username of the target channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Pass True to exclude gifts that aren't saved to the chat's profile page. Always True, unless the bot has the can_post_messages administrator right in the channel.
|
|
ExcludeUnsaved *bool `json:"exclude_unsaved,omitempty"`
|
|
// Pass True to exclude gifts that are saved to the chat's profile page. Always False, unless the bot has the can_post_messages administrator right in the channel.
|
|
ExcludeSaved *bool `json:"exclude_saved,omitempty"`
|
|
// Pass True to exclude gifts that can be purchased an unlimited number of times
|
|
ExcludeUnlimited *bool `json:"exclude_unlimited,omitempty"`
|
|
// Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique
|
|
ExcludeLimitedUpgradable *bool `json:"exclude_limited_upgradable,omitempty"`
|
|
// Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique
|
|
ExcludeLimitedNonUpgradable *bool `json:"exclude_limited_non_upgradable,omitempty"`
|
|
// Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram
|
|
ExcludeFromBlockchain *bool `json:"exclude_from_blockchain,omitempty"`
|
|
// Pass True to exclude unique gifts
|
|
ExcludeUnique *bool `json:"exclude_unique,omitempty"`
|
|
// Pass True to sort results by gift price instead of send date. Sorting is applied before pagination.
|
|
SortByPrice *bool `json:"sort_by_price,omitempty"`
|
|
// Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results
|
|
Offset string `json:"offset,omitempty"`
|
|
// The maximum number of gifts to be returned; 1-100. Defaults to 100.
|
|
Limit *int64 `json:"limit,omitempty"`
|
|
}
|
|
|
|
// GetChatGifts calls the getChatGifts Telegram Bot API method.
|
|
//
|
|
// Returns the gifts owned by a chat. Returns OwnedGifts on success.
|
|
func GetChatGifts(ctx context.Context, b *client.Bot, p *GetChatGiftsParams) (*OwnedGifts, error) {
|
|
return client.Call[*GetChatGiftsParams, *OwnedGifts](ctx, b, "getChatGifts", p)
|
|
}
|
|
|
|
// ConvertGiftToStarsParams is the parameter set for ConvertGiftToStars.
|
|
//
|
|
// Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success.
|
|
type ConvertGiftToStarsParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Unique identifier of the regular gift that should be converted to Telegram Stars
|
|
OwnedGiftID string `json:"owned_gift_id"`
|
|
}
|
|
|
|
// ConvertGiftToStars calls the convertGiftToStars Telegram Bot API method.
|
|
//
|
|
// Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success.
|
|
func ConvertGiftToStars(ctx context.Context, b *client.Bot, p *ConvertGiftToStarsParams) (bool, error) {
|
|
return client.Call[*ConvertGiftToStarsParams, bool](ctx, b, "convertGiftToStars", p)
|
|
}
|
|
|
|
// UpgradeGiftParams is the parameter set for UpgradeGift.
|
|
//
|
|
// Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns True on success.
|
|
type UpgradeGiftParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Unique identifier of the regular gift that should be upgraded to a unique one
|
|
OwnedGiftID string `json:"owned_gift_id"`
|
|
// Pass True to keep the original gift text, sender and receiver in the upgraded gift
|
|
KeepOriginalDetails *bool `json:"keep_original_details,omitempty"`
|
|
// The amount of Telegram Stars that will be paid for the upgrade from the business account balance. If gift.prepaid_upgrade_star_count > 0, then pass 0, otherwise, the can_transfer_stars business bot right is required and gift.upgrade_star_count must be passed.
|
|
StarCount *int64 `json:"star_count,omitempty"`
|
|
}
|
|
|
|
// UpgradeGift calls the upgradeGift Telegram Bot API method.
|
|
//
|
|
// Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns True on success.
|
|
func UpgradeGift(ctx context.Context, b *client.Bot, p *UpgradeGiftParams) (bool, error) {
|
|
return client.Call[*UpgradeGiftParams, bool](ctx, b, "upgradeGift", p)
|
|
}
|
|
|
|
// TransferGiftParams is the parameter set for TransferGift.
|
|
//
|
|
// Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. Requires can_transfer_stars business bot right if the transfer is paid. Returns True on success.
|
|
type TransferGiftParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Unique identifier of the regular gift that should be transferred
|
|
OwnedGiftID string `json:"owned_gift_id"`
|
|
// Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours.
|
|
NewOwnerChatID int64 `json:"new_owner_chat_id"`
|
|
// The amount of Telegram Stars that will be paid for the transfer from the business account balance. If positive, then the can_transfer_stars business bot right is required.
|
|
StarCount *int64 `json:"star_count,omitempty"`
|
|
}
|
|
|
|
// TransferGift calls the transferGift Telegram Bot API method.
|
|
//
|
|
// Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. Requires can_transfer_stars business bot right if the transfer is paid. Returns True on success.
|
|
func TransferGift(ctx context.Context, b *client.Bot, p *TransferGiftParams) (bool, error) {
|
|
return client.Call[*TransferGiftParams, bool](ctx, b, "transferGift", p)
|
|
}
|
|
|
|
// PostStoryParams is the parameter set for PostStory.
|
|
//
|
|
// Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success.
|
|
type PostStoryParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Content of the story
|
|
Content InputStoryContent `json:"content"`
|
|
// Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400
|
|
ActivePeriod int64 `json:"active_period"`
|
|
// Caption of the story, 0-2048 characters after entities parsing
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the story caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// 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"`
|
|
// A JSON-serialized list of clickable areas to be shown on the story
|
|
Areas []StoryArea `json:"areas,omitempty"`
|
|
// Pass True to keep the story accessible after it expires
|
|
PostToChatPage *bool `json:"post_to_chat_page,omitempty"`
|
|
// Pass True if the content of the story must be protected from forwarding and screenshotting
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
}
|
|
|
|
// PostStory calls the postStory Telegram Bot API method.
|
|
//
|
|
// Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success.
|
|
func PostStory(ctx context.Context, b *client.Bot, p *PostStoryParams) (*Story, error) {
|
|
return client.Call[*PostStoryParams, *Story](ctx, b, "postStory", p)
|
|
}
|
|
|
|
// RepostStoryParams is the parameter set for RepostStory.
|
|
//
|
|
// Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success.
|
|
type RepostStoryParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Unique identifier of the chat which posted the story that should be reposted
|
|
FromChatID int64 `json:"from_chat_id"`
|
|
// Unique identifier of the story that should be reposted
|
|
FromStoryID int64 `json:"from_story_id"`
|
|
// Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400
|
|
ActivePeriod int64 `json:"active_period"`
|
|
// Pass True to keep the story accessible after it expires
|
|
PostToChatPage *bool `json:"post_to_chat_page,omitempty"`
|
|
// Pass True if the content of the story must be protected from forwarding and screenshotting
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
}
|
|
|
|
// RepostStory calls the repostStory Telegram Bot API method.
|
|
//
|
|
// Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success.
|
|
func RepostStory(ctx context.Context, b *client.Bot, p *RepostStoryParams) (*Story, error) {
|
|
return client.Call[*RepostStoryParams, *Story](ctx, b, "repostStory", p)
|
|
}
|
|
|
|
// EditStoryParams is the parameter set for EditStory.
|
|
//
|
|
// Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success.
|
|
type EditStoryParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Unique identifier of the story to edit
|
|
StoryID int64 `json:"story_id"`
|
|
// Content of the story
|
|
Content InputStoryContent `json:"content"`
|
|
// Caption of the story, 0-2048 characters after entities parsing
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the story caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// 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"`
|
|
// A JSON-serialized list of clickable areas to be shown on the story
|
|
Areas []StoryArea `json:"areas,omitempty"`
|
|
}
|
|
|
|
// EditStory calls the editStory Telegram Bot API method.
|
|
//
|
|
// Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success.
|
|
func EditStory(ctx context.Context, b *client.Bot, p *EditStoryParams) (*Story, error) {
|
|
return client.Call[*EditStoryParams, *Story](ctx, b, "editStory", p)
|
|
}
|
|
|
|
// DeleteStoryParams is the parameter set for DeleteStory.
|
|
//
|
|
// Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success.
|
|
type DeleteStoryParams struct {
|
|
// Unique identifier of the business connection
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Unique identifier of the story to delete
|
|
StoryID int64 `json:"story_id"`
|
|
}
|
|
|
|
// DeleteStory calls the deleteStory Telegram Bot API method.
|
|
//
|
|
// Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success.
|
|
func DeleteStory(ctx context.Context, b *client.Bot, p *DeleteStoryParams) (bool, error) {
|
|
return client.Call[*DeleteStoryParams, bool](ctx, b, "deleteStory", p)
|
|
}
|
|
|
|
// AnswerWebAppQueryParams is the parameter set for AnswerWebAppQuery.
|
|
//
|
|
// Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned.
|
|
type AnswerWebAppQueryParams struct {
|
|
// Unique identifier for the query to be answered
|
|
WebAppQueryID string `json:"web_app_query_id"`
|
|
// A JSON-serialized object describing the message to be sent
|
|
Result InlineQueryResult `json:"result"`
|
|
}
|
|
|
|
// AnswerWebAppQuery calls the answerWebAppQuery Telegram Bot API method.
|
|
//
|
|
// Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned.
|
|
func AnswerWebAppQuery(ctx context.Context, b *client.Bot, p *AnswerWebAppQueryParams) (*SentWebAppMessage, error) {
|
|
return client.Call[*AnswerWebAppQueryParams, *SentWebAppMessage](ctx, b, "answerWebAppQuery", p)
|
|
}
|
|
|
|
// SavePreparedInlineMessageParams is the parameter set for SavePreparedInlineMessage.
|
|
//
|
|
// Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.
|
|
type SavePreparedInlineMessageParams struct {
|
|
// Unique identifier of the target user that can use the prepared message
|
|
UserID int64 `json:"user_id"`
|
|
// A JSON-serialized object describing the message to be sent
|
|
Result InlineQueryResult `json:"result"`
|
|
// Pass True if the message can be sent to private chats with users
|
|
AllowUserChats *bool `json:"allow_user_chats,omitempty"`
|
|
// Pass True if the message can be sent to private chats with bots
|
|
AllowBotChats *bool `json:"allow_bot_chats,omitempty"`
|
|
// Pass True if the message can be sent to group and supergroup chats
|
|
AllowGroupChats *bool `json:"allow_group_chats,omitempty"`
|
|
// Pass True if the message can be sent to channel chats
|
|
AllowChannelChats *bool `json:"allow_channel_chats,omitempty"`
|
|
}
|
|
|
|
// SavePreparedInlineMessage calls the savePreparedInlineMessage Telegram Bot API method.
|
|
//
|
|
// Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.
|
|
func SavePreparedInlineMessage(ctx context.Context, b *client.Bot, p *SavePreparedInlineMessageParams) (*PreparedInlineMessage, error) {
|
|
return client.Call[*SavePreparedInlineMessageParams, *PreparedInlineMessage](ctx, b, "savePreparedInlineMessage", p)
|
|
}
|
|
|
|
// SavePreparedKeyboardButtonParams is the parameter set for SavePreparedKeyboardButton.
|
|
//
|
|
// Stores a keyboard button that can be used by a user within a Mini App. Returns a PreparedKeyboardButton object.
|
|
type SavePreparedKeyboardButtonParams struct {
|
|
// Unique identifier of the target user that can use the button
|
|
UserID int64 `json:"user_id"`
|
|
// A JSON-serialized object describing the button to be saved. The button must be of the type request_users, request_chat, or request_managed_bot.
|
|
Button KeyboardButton `json:"button"`
|
|
}
|
|
|
|
// SavePreparedKeyboardButton calls the savePreparedKeyboardButton Telegram Bot API method.
|
|
//
|
|
// Stores a keyboard button that can be used by a user within a Mini App. Returns a PreparedKeyboardButton object.
|
|
func SavePreparedKeyboardButton(ctx context.Context, b *client.Bot, p *SavePreparedKeyboardButtonParams) (*PreparedKeyboardButton, error) {
|
|
return client.Call[*SavePreparedKeyboardButtonParams, *PreparedKeyboardButton](ctx, b, "savePreparedKeyboardButton", p)
|
|
}
|
|
|
|
// EditMessageTextParams is the parameter set for EditMessageText.
|
|
//
|
|
// Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
|
|
type EditMessageTextParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.
|
|
ChatID *ChatID `json:"chat_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Identifier of the message to edit.
|
|
MessageID *int64 `json:"message_id,omitempty"`
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message.
|
|
InlineMessageID string `json:"inline_message_id,omitempty"`
|
|
// New text of the message, 1-4096 characters after entities parsing
|
|
Text string `json:"text"`
|
|
// Mode for parsing entities in the message text. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode
|
|
Entities []MessageEntity `json:"entities,omitempty"`
|
|
// Link preview generation options for the message
|
|
LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
|
|
// A JSON-serialized object for an inline keyboard
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// EditMessageText calls the editMessageText Telegram Bot API method.
|
|
//
|
|
// Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
|
|
func EditMessageText(ctx context.Context, b *client.Bot, p *EditMessageTextParams) (*MessageOrBool, error) {
|
|
return client.Call[*EditMessageTextParams, *MessageOrBool](ctx, b, "editMessageText", p)
|
|
}
|
|
|
|
// EditMessageCaptionParams is the parameter set for EditMessageCaption.
|
|
//
|
|
// Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
|
|
type EditMessageCaptionParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.
|
|
ChatID *ChatID `json:"chat_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Identifier of the message to edit.
|
|
MessageID *int64 `json:"message_id,omitempty"`
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message.
|
|
InlineMessageID string `json:"inline_message_id,omitempty"`
|
|
// New caption of the message, 0-1024 characters after entities parsing
|
|
Caption string `json:"caption,omitempty"`
|
|
// Mode for parsing entities in the message caption. See formatting options for more details.
|
|
ParseMode ParseMode `json:"parse_mode,omitempty"`
|
|
// 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"`
|
|
// Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages.
|
|
ShowCaptionAboveMedia *bool `json:"show_caption_above_media,omitempty"`
|
|
// A JSON-serialized object for an inline keyboard
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// EditMessageCaption calls the editMessageCaption Telegram Bot API method.
|
|
//
|
|
// Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
|
|
func EditMessageCaption(ctx context.Context, b *client.Bot, p *EditMessageCaptionParams) (*MessageOrBool, error) {
|
|
return client.Call[*EditMessageCaptionParams, *MessageOrBool](ctx, b, "editMessageCaption", p)
|
|
}
|
|
|
|
// EditMessageMediaParams is the parameter set for EditMessageMedia.
|
|
//
|
|
// Use this method to edit animation, audio, document, live photo, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo, a live photo, or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
|
|
type EditMessageMediaParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.
|
|
ChatID *ChatID `json:"chat_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Identifier of the message to edit.
|
|
MessageID *int64 `json:"message_id,omitempty"`
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message.
|
|
InlineMessageID string `json:"inline_message_id,omitempty"`
|
|
// A JSON-serialized object for a new media content of the message
|
|
Media InputMedia `json:"media"`
|
|
// A JSON-serialized object for a new inline keyboard
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *EditMessageMediaParams) HasFile() bool {
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *EditMessageMediaParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
if !p.ChatID.IsZero() {
|
|
out["chat_id"] = p.ChatID.String()
|
|
}
|
|
if p.MessageID != nil {
|
|
out["message_id"] = strconv.FormatInt(*p.MessageID, 10)
|
|
}
|
|
if p.InlineMessageID != "" {
|
|
out["inline_message_id"] = p.InlineMessageID
|
|
}
|
|
if b, _ := json.Marshal(p.Media); len(b) > 0 {
|
|
out["media"] = string(b)
|
|
}
|
|
if p.ReplyMarkup != nil {
|
|
if b, _ := json.Marshal(p.ReplyMarkup); len(b) > 0 {
|
|
out["reply_markup"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *EditMessageMediaParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
return files
|
|
}
|
|
|
|
// EditMessageMedia calls the editMessageMedia Telegram Bot API method.
|
|
//
|
|
// Use this method to edit animation, audio, document, live photo, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo, a live photo, or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
|
|
func EditMessageMedia(ctx context.Context, b *client.Bot, p *EditMessageMediaParams) (*MessageOrBool, error) {
|
|
return client.Call[*EditMessageMediaParams, *MessageOrBool](ctx, b, "editMessageMedia", p)
|
|
}
|
|
|
|
// EditMessageLiveLocationParams is the parameter set for EditMessageLiveLocation.
|
|
//
|
|
// Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
|
|
type EditMessageLiveLocationParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.
|
|
ChatID *ChatID `json:"chat_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Identifier of the message to edit.
|
|
MessageID *int64 `json:"message_id,omitempty"`
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message.
|
|
InlineMessageID string `json:"inline_message_id,omitempty"`
|
|
// Latitude of new location
|
|
Latitude float64 `json:"latitude"`
|
|
// Longitude of new location
|
|
Longitude float64 `json:"longitude"`
|
|
// New period in seconds during which the location can be updated, starting from the message send date. If 0x7FFFFFFF is specified, then the location can be updated forever. Otherwise, the new value must not exceed the current live_period by more than a day, and the live location expiration date must remain within the next 90 days. If not specified, then live_period remains unchanged.
|
|
LivePeriod *int64 `json:"live_period,omitempty"`
|
|
// The radius of uncertainty for the location, measured in meters; 0-1500
|
|
HorizontalAccuracy *float64 `json:"horizontal_accuracy,omitempty"`
|
|
// Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
|
|
Heading *int64 `json:"heading,omitempty"`
|
|
// The maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
|
|
ProximityAlertRadius *int64 `json:"proximity_alert_radius,omitempty"`
|
|
// A JSON-serialized object for a new inline keyboard
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// EditMessageLiveLocation calls the editMessageLiveLocation Telegram Bot API method.
|
|
//
|
|
// Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
|
|
func EditMessageLiveLocation(ctx context.Context, b *client.Bot, p *EditMessageLiveLocationParams) (*MessageOrBool, error) {
|
|
return client.Call[*EditMessageLiveLocationParams, *MessageOrBool](ctx, b, "editMessageLiveLocation", p)
|
|
}
|
|
|
|
// StopMessageLiveLocationParams is the parameter set for StopMessageLiveLocation.
|
|
//
|
|
// Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.
|
|
type StopMessageLiveLocationParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.
|
|
ChatID *ChatID `json:"chat_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Identifier of the message with live location to stop.
|
|
MessageID *int64 `json:"message_id,omitempty"`
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message.
|
|
InlineMessageID string `json:"inline_message_id,omitempty"`
|
|
// A JSON-serialized object for a new inline keyboard
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// StopMessageLiveLocation calls the stopMessageLiveLocation Telegram Bot API method.
|
|
//
|
|
// Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.
|
|
func StopMessageLiveLocation(ctx context.Context, b *client.Bot, p *StopMessageLiveLocationParams) (*MessageOrBool, error) {
|
|
return client.Call[*StopMessageLiveLocationParams, *MessageOrBool](ctx, b, "stopMessageLiveLocation", p)
|
|
}
|
|
|
|
// EditMessageChecklistParams is the parameter set for EditMessageChecklist.
|
|
//
|
|
// Use this method to edit a checklist on behalf of a connected business account. On success, the edited Message is returned.
|
|
type EditMessageChecklistParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id"`
|
|
// Unique identifier for the target chat or username of the target bot in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Unique identifier for the target message
|
|
MessageID int64 `json:"message_id"`
|
|
// A JSON-serialized object for the new checklist
|
|
Checklist InputChecklist `json:"checklist"`
|
|
// A JSON-serialized object for the new inline keyboard for the message
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// EditMessageChecklist calls the editMessageChecklist Telegram Bot API method.
|
|
//
|
|
// Use this method to edit a checklist on behalf of a connected business account. On success, the edited Message is returned.
|
|
func EditMessageChecklist(ctx context.Context, b *client.Bot, p *EditMessageChecklistParams) (*Message, error) {
|
|
return client.Call[*EditMessageChecklistParams, *Message](ctx, b, "editMessageChecklist", p)
|
|
}
|
|
|
|
// EditMessageReplyMarkupParams is the parameter set for EditMessageReplyMarkup.
|
|
//
|
|
// Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
|
|
type EditMessageReplyMarkupParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.
|
|
ChatID *ChatID `json:"chat_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Identifier of the message to edit.
|
|
MessageID *int64 `json:"message_id,omitempty"`
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message.
|
|
InlineMessageID string `json:"inline_message_id,omitempty"`
|
|
// A JSON-serialized object for an inline keyboard
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// EditMessageReplyMarkup calls the editMessageReplyMarkup Telegram Bot API method.
|
|
//
|
|
// Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
|
|
func EditMessageReplyMarkup(ctx context.Context, b *client.Bot, p *EditMessageReplyMarkupParams) (*MessageOrBool, error) {
|
|
return client.Call[*EditMessageReplyMarkupParams, *MessageOrBool](ctx, b, "editMessageReplyMarkup", p)
|
|
}
|
|
|
|
// StopPollParams is the parameter set for StopPoll.
|
|
//
|
|
// Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned.
|
|
type StopPollParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Identifier of the original message with the poll
|
|
MessageID int64 `json:"message_id"`
|
|
// A JSON-serialized object for a new message inline keyboard
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// StopPoll calls the stopPoll Telegram Bot API method.
|
|
//
|
|
// Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned.
|
|
func StopPoll(ctx context.Context, b *client.Bot, p *StopPollParams) (*Poll, error) {
|
|
return client.Call[*StopPollParams, *Poll](ctx, b, "stopPoll", p)
|
|
}
|
|
|
|
// ApproveSuggestedPostParams is the parameter set for ApproveSuggestedPost.
|
|
//
|
|
// Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success.
|
|
type ApproveSuggestedPostParams struct {
|
|
// Unique identifier for the target direct messages chat
|
|
ChatID int64 `json:"chat_id"`
|
|
// Identifier of a suggested post message to approve
|
|
MessageID int64 `json:"message_id"`
|
|
// Point in time (Unix timestamp) when the post is expected to be published; omit if the date has already been specified when the suggested post was created. If specified, then the date must be not more than 2678400 seconds (30 days) in the future.
|
|
SendDate *int64 `json:"send_date,omitempty"`
|
|
}
|
|
|
|
// ApproveSuggestedPost calls the approveSuggestedPost Telegram Bot API method.
|
|
//
|
|
// Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success.
|
|
func ApproveSuggestedPost(ctx context.Context, b *client.Bot, p *ApproveSuggestedPostParams) (bool, error) {
|
|
return client.Call[*ApproveSuggestedPostParams, bool](ctx, b, "approveSuggestedPost", p)
|
|
}
|
|
|
|
// DeclineSuggestedPostParams is the parameter set for DeclineSuggestedPost.
|
|
//
|
|
// Use this method to decline a suggested post in a direct messages chat. The bot must have the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success.
|
|
type DeclineSuggestedPostParams struct {
|
|
// Unique identifier for the target direct messages chat
|
|
ChatID int64 `json:"chat_id"`
|
|
// Identifier of a suggested post message to decline
|
|
MessageID int64 `json:"message_id"`
|
|
// Comment for the creator of the suggested post; 0-128 characters
|
|
Comment string `json:"comment,omitempty"`
|
|
}
|
|
|
|
// DeclineSuggestedPost calls the declineSuggestedPost Telegram Bot API method.
|
|
//
|
|
// Use this method to decline a suggested post in a direct messages chat. The bot must have the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success.
|
|
func DeclineSuggestedPost(ctx context.Context, b *client.Bot, p *DeclineSuggestedPostParams) (bool, error) {
|
|
return client.Call[*DeclineSuggestedPostParams, bool](ctx, b, "declineSuggestedPost", p)
|
|
}
|
|
|
|
// DeleteMessageParams is the parameter set for DeleteMessage.
|
|
//
|
|
// Use this method to delete a message, including service messages, with the following limitations:- A message can only be deleted if it was sent less than 48 hours ago.- Service messages about a supergroup, channel, or forum topic creation can't be deleted.- A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.- Bots can delete outgoing messages in private chats, groups, and supergroups.- Bots can delete incoming messages in private chats.- Bots granted can_post_messages permissions can delete outgoing messages in channels.- If the bot is an administrator of a group, it can delete any message there.- If the bot has can_delete_messages administrator right in a supergroup or a channel, it can delete any message there.- If the bot has can_manage_direct_messages administrator right in a channel, it can delete any message in the corresponding direct messages chat.Returns True on success.
|
|
type DeleteMessageParams struct {
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Identifier of the message to delete
|
|
MessageID int64 `json:"message_id"`
|
|
}
|
|
|
|
// DeleteMessage calls the deleteMessage Telegram Bot API method.
|
|
//
|
|
// Use this method to delete a message, including service messages, with the following limitations:- A message can only be deleted if it was sent less than 48 hours ago.- Service messages about a supergroup, channel, or forum topic creation can't be deleted.- A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.- Bots can delete outgoing messages in private chats, groups, and supergroups.- Bots can delete incoming messages in private chats.- Bots granted can_post_messages permissions can delete outgoing messages in channels.- If the bot is an administrator of a group, it can delete any message there.- If the bot has can_delete_messages administrator right in a supergroup or a channel, it can delete any message there.- If the bot has can_manage_direct_messages administrator right in a channel, it can delete any message in the corresponding direct messages chat.Returns True on success.
|
|
func DeleteMessage(ctx context.Context, b *client.Bot, p *DeleteMessageParams) (bool, error) {
|
|
return client.Call[*DeleteMessageParams, bool](ctx, b, "deleteMessage", p)
|
|
}
|
|
|
|
// DeleteMessagesParams is the parameter set for DeleteMessages.
|
|
//
|
|
// Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped. Returns True on success.
|
|
type DeleteMessagesParams struct {
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// A JSON-serialized list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted.
|
|
MessageIds []int64 `json:"message_ids"`
|
|
}
|
|
|
|
// DeleteMessages calls the deleteMessages Telegram Bot API method.
|
|
//
|
|
// Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped. Returns True on success.
|
|
func DeleteMessages(ctx context.Context, b *client.Bot, p *DeleteMessagesParams) (bool, error) {
|
|
return client.Call[*DeleteMessagesParams, bool](ctx, b, "deleteMessages", p)
|
|
}
|
|
|
|
// DeleteMessageReactionParams is the parameter set for DeleteMessageReaction.
|
|
//
|
|
// Use this method to remove a reaction from a message in a group or a supergroup chat. The bot must have the 'can_delete_messages' administrator right in the chat. Returns True on success.
|
|
type DeleteMessageReactionParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Identifier of the target message
|
|
MessageID int64 `json:"message_id"`
|
|
// Identifier of the user whose reaction will be removed, if the reaction was added by a user
|
|
UserID *int64 `json:"user_id,omitempty"`
|
|
// Identifier of the chat whose reaction will be removed, if the reaction was added by a chat
|
|
ActorChatID *int64 `json:"actor_chat_id,omitempty"`
|
|
}
|
|
|
|
// DeleteMessageReaction calls the deleteMessageReaction Telegram Bot API method.
|
|
//
|
|
// Use this method to remove a reaction from a message in a group or a supergroup chat. The bot must have the 'can_delete_messages' administrator right in the chat. Returns True on success.
|
|
func DeleteMessageReaction(ctx context.Context, b *client.Bot, p *DeleteMessageReactionParams) (bool, error) {
|
|
return client.Call[*DeleteMessageReactionParams, bool](ctx, b, "deleteMessageReaction", p)
|
|
}
|
|
|
|
// DeleteAllMessageReactionsParams is the parameter set for DeleteAllMessageReactions.
|
|
//
|
|
// Use this method to remove up to 10000 recent reactions in a group or a supergroup chat added by a given user or chat. The bot must have the 'can_delete_messages' administrator right in the chat. Returns True on success.
|
|
type DeleteAllMessageReactionsParams struct {
|
|
// Unique identifier for the target chat or username of the target supergroup in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// Identifier of the user whose reactions will be removed, if the reactions were added by a user
|
|
UserID *int64 `json:"user_id,omitempty"`
|
|
// Identifier of the chat whose reactions will be removed, if the reactions were added by a chat
|
|
ActorChatID *int64 `json:"actor_chat_id,omitempty"`
|
|
}
|
|
|
|
// DeleteAllMessageReactions calls the deleteAllMessageReactions Telegram Bot API method.
|
|
//
|
|
// Use this method to remove up to 10000 recent reactions in a group or a supergroup chat added by a given user or chat. The bot must have the 'can_delete_messages' administrator right in the chat. Returns True on success.
|
|
func DeleteAllMessageReactions(ctx context.Context, b *client.Bot, p *DeleteAllMessageReactionsParams) (bool, error) {
|
|
return client.Call[*DeleteAllMessageReactionsParams, bool](ctx, b, "deleteAllMessageReactions", p)
|
|
}
|
|
|
|
// SendStickerParams is the parameter set for SendSticker.
|
|
//
|
|
// Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned.
|
|
type SendStickerParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// Sticker 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 .WEBP sticker from the Internet, or upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data. More information on Sending Files ». Video and animated stickers can't be sent via an HTTP URL.
|
|
Sticker *InputFile `json:"sticker"`
|
|
// Emoji associated with the sticker; only for just uploaded stickers
|
|
Emoji string `json:"emoji,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// 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 any `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SendStickerParams) HasFile() bool {
|
|
if p.Sticker != nil && p.Sticker.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SendStickerParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
if p.BusinessConnectionID != "" {
|
|
out["business_connection_id"] = p.BusinessConnectionID
|
|
}
|
|
out["chat_id"] = p.ChatID.String()
|
|
if p.MessageThreadID != nil {
|
|
out["message_thread_id"] = strconv.FormatInt(*p.MessageThreadID, 10)
|
|
}
|
|
if p.DirectMessagesTopicID != nil {
|
|
out["direct_messages_topic_id"] = strconv.FormatInt(*p.DirectMessagesTopicID, 10)
|
|
}
|
|
if p.Emoji != "" {
|
|
out["emoji"] = p.Emoji
|
|
}
|
|
if p.DisableNotification != nil {
|
|
out["disable_notification"] = strconv.FormatBool(*p.DisableNotification)
|
|
}
|
|
if p.ProtectContent != nil {
|
|
out["protect_content"] = strconv.FormatBool(*p.ProtectContent)
|
|
}
|
|
if p.AllowPaidBroadcast != nil {
|
|
out["allow_paid_broadcast"] = strconv.FormatBool(*p.AllowPaidBroadcast)
|
|
}
|
|
if p.MessageEffectID != "" {
|
|
out["message_effect_id"] = p.MessageEffectID
|
|
}
|
|
if p.SuggestedPostParameters != nil {
|
|
if b, _ := json.Marshal(p.SuggestedPostParameters); len(b) > 0 {
|
|
out["suggested_post_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyParameters != nil {
|
|
if b, _ := json.Marshal(p.ReplyParameters); len(b) > 0 {
|
|
out["reply_parameters"] = string(b)
|
|
}
|
|
}
|
|
if p.ReplyMarkup != nil {
|
|
if b, _ := json.Marshal(p.ReplyMarkup); len(b) > 0 && string(b) != "null" {
|
|
out["reply_markup"] = string(b)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SendStickerParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.Sticker != nil && p.Sticker.IsLocalUpload() {
|
|
name := p.Sticker.Filename
|
|
if name == "" {
|
|
name = "sticker"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "sticker", Filename: name, Reader: p.Sticker.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SendSticker calls the sendSticker Telegram Bot API method.
|
|
//
|
|
// Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned.
|
|
func SendSticker(ctx context.Context, b *client.Bot, p *SendStickerParams) (*Message, error) {
|
|
return client.Call[*SendStickerParams, *Message](ctx, b, "sendSticker", p)
|
|
}
|
|
|
|
// GetStickerSetParams is the parameter set for GetStickerSet.
|
|
//
|
|
// Use this method to get a sticker set. On success, a StickerSet object is returned.
|
|
type GetStickerSetParams struct {
|
|
// Name of the sticker set
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// GetStickerSet calls the getStickerSet Telegram Bot API method.
|
|
//
|
|
// Use this method to get a sticker set. On success, a StickerSet object is returned.
|
|
func GetStickerSet(ctx context.Context, b *client.Bot, p *GetStickerSetParams) (*StickerSet, error) {
|
|
return client.Call[*GetStickerSetParams, *StickerSet](ctx, b, "getStickerSet", p)
|
|
}
|
|
|
|
// GetCustomEmojiStickersParams is the parameter set for GetCustomEmojiStickers.
|
|
//
|
|
// Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects.
|
|
type GetCustomEmojiStickersParams struct {
|
|
// A JSON-serialized list of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
|
|
CustomEmojiIds []string `json:"custom_emoji_ids"`
|
|
}
|
|
|
|
// GetCustomEmojiStickers calls the getCustomEmojiStickers Telegram Bot API method.
|
|
//
|
|
// Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects.
|
|
func GetCustomEmojiStickers(ctx context.Context, b *client.Bot, p *GetCustomEmojiStickersParams) ([]Sticker, error) {
|
|
return client.Call[*GetCustomEmojiStickersParams, []Sticker](ctx, b, "getCustomEmojiStickers", p)
|
|
}
|
|
|
|
// UploadStickerFileParams is the parameter set for UploadStickerFile.
|
|
//
|
|
// Use this method to upload a file with a sticker for later use in the createNewStickerSet, addStickerToSet, or replaceStickerInSet methods (the file can be used multiple times). Returns the uploaded File on success.
|
|
type UploadStickerFileParams struct {
|
|
// User identifier of sticker file owner
|
|
UserID int64 `json:"user_id"`
|
|
// A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See https://core.telegram.org/stickers for technical requirements. More information on Sending Files »
|
|
Sticker *InputFile `json:"sticker"`
|
|
// Format of the sticker, must be one of “static”, “animated”, “video”
|
|
StickerFormat InputStickerFormat `json:"sticker_format"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *UploadStickerFileParams) HasFile() bool {
|
|
if p.Sticker != nil && p.Sticker.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *UploadStickerFileParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
out["user_id"] = strconv.FormatInt(p.UserID, 10)
|
|
out["sticker_format"] = string(p.StickerFormat)
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *UploadStickerFileParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.Sticker != nil && p.Sticker.IsLocalUpload() {
|
|
name := p.Sticker.Filename
|
|
if name == "" {
|
|
name = "sticker"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "sticker", Filename: name, Reader: p.Sticker.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// UploadStickerFile calls the uploadStickerFile Telegram Bot API method.
|
|
//
|
|
// Use this method to upload a file with a sticker for later use in the createNewStickerSet, addStickerToSet, or replaceStickerInSet methods (the file can be used multiple times). Returns the uploaded File on success.
|
|
func UploadStickerFile(ctx context.Context, b *client.Bot, p *UploadStickerFileParams) (*File, error) {
|
|
return client.Call[*UploadStickerFileParams, *File](ctx, b, "uploadStickerFile", p)
|
|
}
|
|
|
|
// CreateNewStickerSetParams is the parameter set for CreateNewStickerSet.
|
|
//
|
|
// Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success.
|
|
type CreateNewStickerSetParams struct {
|
|
// User identifier of created sticker set owner
|
|
UserID int64 `json:"user_id"`
|
|
// Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "_by_<bot_username>". <bot_username> is case insensitive. 1-64 characters.
|
|
Name string `json:"name"`
|
|
// Sticker set title, 1-64 characters
|
|
Title string `json:"title"`
|
|
// A JSON-serialized list of 1-50 initial stickers to be added to the sticker set
|
|
Stickers []InputSticker `json:"stickers"`
|
|
// Type of stickers in the set, pass “regular”, “mask”, or “custom_emoji”. By default, a regular sticker set is created.
|
|
StickerType string `json:"sticker_type,omitempty"`
|
|
// Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only
|
|
NeedsRepainting *bool `json:"needs_repainting,omitempty"`
|
|
}
|
|
|
|
// CreateNewStickerSet calls the createNewStickerSet Telegram Bot API method.
|
|
//
|
|
// Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success.
|
|
func CreateNewStickerSet(ctx context.Context, b *client.Bot, p *CreateNewStickerSetParams) (bool, error) {
|
|
return client.Call[*CreateNewStickerSetParams, bool](ctx, b, "createNewStickerSet", p)
|
|
}
|
|
|
|
// AddStickerToSetParams is the parameter set for AddStickerToSet.
|
|
//
|
|
// Use this method to add a new sticker to a set created by the bot. Emoji sticker sets can have up to 200 stickers. Other sticker sets can have up to 120 stickers. Returns True on success.
|
|
type AddStickerToSetParams struct {
|
|
// User identifier of sticker set owner
|
|
UserID int64 `json:"user_id"`
|
|
// Sticker set name
|
|
Name string `json:"name"`
|
|
// A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn't changed.
|
|
Sticker InputSticker `json:"sticker"`
|
|
}
|
|
|
|
// AddStickerToSet calls the addStickerToSet Telegram Bot API method.
|
|
//
|
|
// Use this method to add a new sticker to a set created by the bot. Emoji sticker sets can have up to 200 stickers. Other sticker sets can have up to 120 stickers. Returns True on success.
|
|
func AddStickerToSet(ctx context.Context, b *client.Bot, p *AddStickerToSetParams) (bool, error) {
|
|
return client.Call[*AddStickerToSetParams, bool](ctx, b, "addStickerToSet", p)
|
|
}
|
|
|
|
// SetStickerPositionInSetParams is the parameter set for SetStickerPositionInSet.
|
|
//
|
|
// Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success.
|
|
type SetStickerPositionInSetParams struct {
|
|
// File identifier of the sticker
|
|
Sticker string `json:"sticker"`
|
|
// New sticker position in the set, zero-based
|
|
Position int64 `json:"position"`
|
|
}
|
|
|
|
// SetStickerPositionInSet calls the setStickerPositionInSet Telegram Bot API method.
|
|
//
|
|
// Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success.
|
|
func SetStickerPositionInSet(ctx context.Context, b *client.Bot, p *SetStickerPositionInSetParams) (bool, error) {
|
|
return client.Call[*SetStickerPositionInSetParams, bool](ctx, b, "setStickerPositionInSet", p)
|
|
}
|
|
|
|
// DeleteStickerFromSetParams is the parameter set for DeleteStickerFromSet.
|
|
//
|
|
// Use this method to delete a sticker from a set created by the bot. Returns True on success.
|
|
type DeleteStickerFromSetParams struct {
|
|
// File identifier of the sticker
|
|
Sticker string `json:"sticker"`
|
|
}
|
|
|
|
// DeleteStickerFromSet calls the deleteStickerFromSet Telegram Bot API method.
|
|
//
|
|
// Use this method to delete a sticker from a set created by the bot. Returns True on success.
|
|
func DeleteStickerFromSet(ctx context.Context, b *client.Bot, p *DeleteStickerFromSetParams) (bool, error) {
|
|
return client.Call[*DeleteStickerFromSetParams, bool](ctx, b, "deleteStickerFromSet", p)
|
|
}
|
|
|
|
// ReplaceStickerInSetParams is the parameter set for ReplaceStickerInSet.
|
|
//
|
|
// Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. Returns True on success.
|
|
type ReplaceStickerInSetParams struct {
|
|
// User identifier of the sticker set owner
|
|
UserID int64 `json:"user_id"`
|
|
// Sticker set name
|
|
Name string `json:"name"`
|
|
// File identifier of the replaced sticker
|
|
OldSticker string `json:"old_sticker"`
|
|
// A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged.
|
|
Sticker InputSticker `json:"sticker"`
|
|
}
|
|
|
|
// ReplaceStickerInSet calls the replaceStickerInSet Telegram Bot API method.
|
|
//
|
|
// Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. Returns True on success.
|
|
func ReplaceStickerInSet(ctx context.Context, b *client.Bot, p *ReplaceStickerInSetParams) (bool, error) {
|
|
return client.Call[*ReplaceStickerInSetParams, bool](ctx, b, "replaceStickerInSet", p)
|
|
}
|
|
|
|
// SetStickerEmojiListParams is the parameter set for SetStickerEmojiList.
|
|
//
|
|
// Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success.
|
|
type SetStickerEmojiListParams struct {
|
|
// File identifier of the sticker
|
|
Sticker string `json:"sticker"`
|
|
// A JSON-serialized list of 1-20 emoji associated with the sticker
|
|
EmojiList []string `json:"emoji_list"`
|
|
}
|
|
|
|
// SetStickerEmojiList calls the setStickerEmojiList Telegram Bot API method.
|
|
//
|
|
// Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success.
|
|
func SetStickerEmojiList(ctx context.Context, b *client.Bot, p *SetStickerEmojiListParams) (bool, error) {
|
|
return client.Call[*SetStickerEmojiListParams, bool](ctx, b, "setStickerEmojiList", p)
|
|
}
|
|
|
|
// SetStickerKeywordsParams is the parameter set for SetStickerKeywords.
|
|
//
|
|
// Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success.
|
|
type SetStickerKeywordsParams struct {
|
|
// File identifier of the sticker
|
|
Sticker string `json:"sticker"`
|
|
// A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters
|
|
Keywords []string `json:"keywords,omitempty"`
|
|
}
|
|
|
|
// SetStickerKeywords calls the setStickerKeywords Telegram Bot API method.
|
|
//
|
|
// Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success.
|
|
func SetStickerKeywords(ctx context.Context, b *client.Bot, p *SetStickerKeywordsParams) (bool, error) {
|
|
return client.Call[*SetStickerKeywordsParams, bool](ctx, b, "setStickerKeywords", p)
|
|
}
|
|
|
|
// SetStickerMaskPositionParams is the parameter set for SetStickerMaskPosition.
|
|
//
|
|
// Use this method to change the mask position of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns True on success.
|
|
type SetStickerMaskPositionParams struct {
|
|
// File identifier of the sticker
|
|
Sticker string `json:"sticker"`
|
|
// A JSON-serialized object with the position where the mask should be placed on faces. Omit the parameter to remove the mask position.
|
|
MaskPosition *MaskPosition `json:"mask_position,omitempty"`
|
|
}
|
|
|
|
// SetStickerMaskPosition calls the setStickerMaskPosition Telegram Bot API method.
|
|
//
|
|
// Use this method to change the mask position of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns True on success.
|
|
func SetStickerMaskPosition(ctx context.Context, b *client.Bot, p *SetStickerMaskPositionParams) (bool, error) {
|
|
return client.Call[*SetStickerMaskPositionParams, bool](ctx, b, "setStickerMaskPosition", p)
|
|
}
|
|
|
|
// SetStickerSetTitleParams is the parameter set for SetStickerSetTitle.
|
|
//
|
|
// Use this method to set the title of a created sticker set. Returns True on success.
|
|
type SetStickerSetTitleParams struct {
|
|
// Sticker set name
|
|
Name string `json:"name"`
|
|
// Sticker set title, 1-64 characters
|
|
Title string `json:"title"`
|
|
}
|
|
|
|
// SetStickerSetTitle calls the setStickerSetTitle Telegram Bot API method.
|
|
//
|
|
// Use this method to set the title of a created sticker set. Returns True on success.
|
|
func SetStickerSetTitle(ctx context.Context, b *client.Bot, p *SetStickerSetTitleParams) (bool, error) {
|
|
return client.Call[*SetStickerSetTitleParams, bool](ctx, b, "setStickerSetTitle", p)
|
|
}
|
|
|
|
// SetStickerSetThumbnailParams is the parameter set for SetStickerSetThumbnail.
|
|
//
|
|
// Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success.
|
|
type SetStickerSetThumbnailParams struct {
|
|
// Sticker set name
|
|
Name string `json:"name"`
|
|
// User identifier of the sticker set owner
|
|
UserID int64 `json:"user_id"`
|
|
// A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a .WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, 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 ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail.
|
|
Thumbnail *InputFile `json:"thumbnail,omitempty"`
|
|
// Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a .WEBM video
|
|
Format InputStickerFormat `json:"format"`
|
|
}
|
|
|
|
// HasFile reports whether a multipart upload is required.
|
|
func (p *SetStickerSetThumbnailParams) HasFile() bool {
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MultipartFields returns the non-file fields used in the multipart body.
|
|
func (p *SetStickerSetThumbnailParams) MultipartFields() map[string]string {
|
|
out := map[string]string{}
|
|
out["name"] = p.Name
|
|
out["user_id"] = strconv.FormatInt(p.UserID, 10)
|
|
out["format"] = string(p.Format)
|
|
return out
|
|
}
|
|
|
|
// MultipartFiles returns the file parts.
|
|
func (p *SetStickerSetThumbnailParams) MultipartFiles() []client.MultipartFile {
|
|
var files []client.MultipartFile
|
|
if p.Thumbnail != nil && p.Thumbnail.IsLocalUpload() {
|
|
name := p.Thumbnail.Filename
|
|
if name == "" {
|
|
name = "thumbnail"
|
|
}
|
|
files = append(files, client.MultipartFile{FieldName: "thumbnail", Filename: name, Reader: p.Thumbnail.Reader})
|
|
}
|
|
return files
|
|
}
|
|
|
|
// SetStickerSetThumbnail calls the setStickerSetThumbnail Telegram Bot API method.
|
|
//
|
|
// Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success.
|
|
func SetStickerSetThumbnail(ctx context.Context, b *client.Bot, p *SetStickerSetThumbnailParams) (bool, error) {
|
|
return client.Call[*SetStickerSetThumbnailParams, bool](ctx, b, "setStickerSetThumbnail", p)
|
|
}
|
|
|
|
// SetCustomEmojiStickerSetThumbnailParams is the parameter set for SetCustomEmojiStickerSetThumbnail.
|
|
//
|
|
// Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success.
|
|
type SetCustomEmojiStickerSetThumbnailParams struct {
|
|
// Sticker set name
|
|
Name string `json:"name"`
|
|
// Custom emoji identifier of a sticker from the sticker set; pass an empty string to drop the thumbnail and use the first sticker as the thumbnail
|
|
CustomEmojiID string `json:"custom_emoji_id,omitempty"`
|
|
}
|
|
|
|
// SetCustomEmojiStickerSetThumbnail calls the setCustomEmojiStickerSetThumbnail Telegram Bot API method.
|
|
//
|
|
// Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success.
|
|
func SetCustomEmojiStickerSetThumbnail(ctx context.Context, b *client.Bot, p *SetCustomEmojiStickerSetThumbnailParams) (bool, error) {
|
|
return client.Call[*SetCustomEmojiStickerSetThumbnailParams, bool](ctx, b, "setCustomEmojiStickerSetThumbnail", p)
|
|
}
|
|
|
|
// DeleteStickerSetParams is the parameter set for DeleteStickerSet.
|
|
//
|
|
// Use this method to delete a sticker set that was created by the bot. Returns True on success.
|
|
type DeleteStickerSetParams struct {
|
|
// Sticker set name
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// DeleteStickerSet calls the deleteStickerSet Telegram Bot API method.
|
|
//
|
|
// Use this method to delete a sticker set that was created by the bot. Returns True on success.
|
|
func DeleteStickerSet(ctx context.Context, b *client.Bot, p *DeleteStickerSetParams) (bool, error) {
|
|
return client.Call[*DeleteStickerSetParams, bool](ctx, b, "deleteStickerSet", p)
|
|
}
|
|
|
|
// AnswerInlineQueryParams is the parameter set for AnswerInlineQuery.
|
|
//
|
|
// Use this method to send answers to an inline query. On success, True is returned.No more than 50 results per query are allowed.
|
|
type AnswerInlineQueryParams struct {
|
|
// Unique identifier for the answered query
|
|
InlineQueryID string `json:"inline_query_id"`
|
|
// A JSON-serialized array of results for the inline query
|
|
Results []InlineQueryResult `json:"results"`
|
|
// The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
|
|
CacheTime *int64 `json:"cache_time,omitempty"`
|
|
// Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query.
|
|
IsPersonal *bool `json:"is_personal,omitempty"`
|
|
// Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.
|
|
NextOffset string `json:"next_offset,omitempty"`
|
|
// A JSON-serialized object describing a button to be shown above inline query results
|
|
Button *InlineQueryResultsButton `json:"button,omitempty"`
|
|
}
|
|
|
|
// AnswerInlineQuery calls the answerInlineQuery Telegram Bot API method.
|
|
//
|
|
// Use this method to send answers to an inline query. On success, True is returned.No more than 50 results per query are allowed.
|
|
func AnswerInlineQuery(ctx context.Context, b *client.Bot, p *AnswerInlineQueryParams) (bool, error) {
|
|
return client.Call[*AnswerInlineQueryParams, bool](ctx, b, "answerInlineQuery", p)
|
|
}
|
|
|
|
// SendInvoiceParams is the parameter set for SendInvoice.
|
|
//
|
|
// Use this method to send invoices. On success, the sent Message is returned.
|
|
type SendInvoiceParams struct {
|
|
// Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// 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 *int64 `json:"direct_messages_topic_id,omitempty"`
|
|
// Product name, 1-32 characters
|
|
Title string `json:"title"`
|
|
// Product description, 1-255 characters
|
|
Description string `json:"description"`
|
|
// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
|
|
Payload string `json:"payload"`
|
|
// Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
|
|
ProviderToken string `json:"provider_token,omitempty"`
|
|
// Three-letter ISO 4217 currency code, see more on currencies. Pass “XTR” for payments in Telegram Stars.
|
|
Currency string `json:"currency"`
|
|
// Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.
|
|
Prices []LabeledPrice `json:"prices"`
|
|
// The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars.
|
|
MaxTipAmount *int64 `json:"max_tip_amount,omitempty"`
|
|
// A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
|
|
SuggestedTipAmounts []int64 `json:"suggested_tip_amounts,omitempty"`
|
|
// Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter.
|
|
StartParameter string `json:"start_parameter,omitempty"`
|
|
// JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.
|
|
ProviderData string `json:"provider_data,omitempty"`
|
|
// URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.
|
|
PhotoURL string `json:"photo_url,omitempty"`
|
|
// Photo size in bytes
|
|
PhotoSize *int64 `json:"photo_size,omitempty"`
|
|
// Photo width
|
|
PhotoWidth *int64 `json:"photo_width,omitempty"`
|
|
// Photo height
|
|
PhotoHeight *int64 `json:"photo_height,omitempty"`
|
|
// Pass True if you require the user's full name to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedName *bool `json:"need_name,omitempty"`
|
|
// Pass True if you require the user's phone number to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedPhoneNumber *bool `json:"need_phone_number,omitempty"`
|
|
// Pass True if you require the user's email address to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedEmail *bool `json:"need_email,omitempty"`
|
|
// Pass True if you require the user's shipping address to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedShippingAddress *bool `json:"need_shipping_address,omitempty"`
|
|
// Pass True if the user's phone number should be sent to the provider. Ignored for payments in Telegram Stars.
|
|
SendPhoneNumberToProvider *bool `json:"send_phone_number_to_provider,omitempty"`
|
|
// Pass True if the user's email address should be sent to the provider. Ignored for payments in Telegram Stars.
|
|
SendEmailToProvider *bool `json:"send_email_to_provider,omitempty"`
|
|
// Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars.
|
|
IsFlexible *bool `json:"is_flexible,omitempty"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// 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"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,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"`
|
|
}
|
|
|
|
// SendInvoice calls the sendInvoice Telegram Bot API method.
|
|
//
|
|
// Use this method to send invoices. On success, the sent Message is returned.
|
|
func SendInvoice(ctx context.Context, b *client.Bot, p *SendInvoiceParams) (*Message, error) {
|
|
return client.Call[*SendInvoiceParams, *Message](ctx, b, "sendInvoice", p)
|
|
}
|
|
|
|
// CreateInvoiceLinkParams is the parameter set for CreateInvoiceLink.
|
|
//
|
|
// Use this method to create a link for an invoice. Returns the created invoice link as String on success.
|
|
type CreateInvoiceLinkParams struct {
|
|
// Unique identifier of the business connection on behalf of which the link will be created. For payments in Telegram Stars only.
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Product name, 1-32 characters
|
|
Title string `json:"title"`
|
|
// Product description, 1-255 characters
|
|
Description string `json:"description"`
|
|
// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
|
|
Payload string `json:"payload"`
|
|
// Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
|
|
ProviderToken string `json:"provider_token,omitempty"`
|
|
// Three-letter ISO 4217 currency code, see more on currencies. Pass “XTR” for payments in Telegram Stars.
|
|
Currency string `json:"currency"`
|
|
// Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.
|
|
Prices []LabeledPrice `json:"prices"`
|
|
// The number of seconds the subscription will be active for before the next payment. The currency must be set to “XTR” (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent subscriptions from the same user. Subscription price must no exceed 10000 Telegram Stars.
|
|
SubscriptionPeriod *int64 `json:"subscription_period,omitempty"`
|
|
// The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars.
|
|
MaxTipAmount *int64 `json:"max_tip_amount,omitempty"`
|
|
// A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
|
|
SuggestedTipAmounts []int64 `json:"suggested_tip_amounts,omitempty"`
|
|
// JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.
|
|
ProviderData string `json:"provider_data,omitempty"`
|
|
// URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.
|
|
PhotoURL string `json:"photo_url,omitempty"`
|
|
// Photo size in bytes
|
|
PhotoSize *int64 `json:"photo_size,omitempty"`
|
|
// Photo width
|
|
PhotoWidth *int64 `json:"photo_width,omitempty"`
|
|
// Photo height
|
|
PhotoHeight *int64 `json:"photo_height,omitempty"`
|
|
// Pass True if you require the user's full name to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedName *bool `json:"need_name,omitempty"`
|
|
// Pass True if you require the user's phone number to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedPhoneNumber *bool `json:"need_phone_number,omitempty"`
|
|
// Pass True if you require the user's email address to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedEmail *bool `json:"need_email,omitempty"`
|
|
// Pass True if you require the user's shipping address to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedShippingAddress *bool `json:"need_shipping_address,omitempty"`
|
|
// Pass True if the user's phone number should be sent to the provider. Ignored for payments in Telegram Stars.
|
|
SendPhoneNumberToProvider *bool `json:"send_phone_number_to_provider,omitempty"`
|
|
// Pass True if the user's email address should be sent to the provider. Ignored for payments in Telegram Stars.
|
|
SendEmailToProvider *bool `json:"send_email_to_provider,omitempty"`
|
|
// Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars.
|
|
IsFlexible *bool `json:"is_flexible,omitempty"`
|
|
}
|
|
|
|
// CreateInvoiceLink calls the createInvoiceLink Telegram Bot API method.
|
|
//
|
|
// Use this method to create a link for an invoice. Returns the created invoice link as String on success.
|
|
func CreateInvoiceLink(ctx context.Context, b *client.Bot, p *CreateInvoiceLinkParams) (string, error) {
|
|
return client.Call[*CreateInvoiceLinkParams, string](ctx, b, "createInvoiceLink", p)
|
|
}
|
|
|
|
// AnswerShippingQueryParams is the parameter set for AnswerShippingQuery.
|
|
//
|
|
// If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
|
|
type AnswerShippingQueryParams struct {
|
|
// Unique identifier for the query to be answered
|
|
ShippingQueryID string `json:"shipping_query_id"`
|
|
// Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)
|
|
Ok bool `json:"ok"`
|
|
// Required if ok is True. A JSON-serialized array of available shipping options.
|
|
ShippingOptions []ShippingOption `json:"shipping_options,omitempty"`
|
|
// Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. “Sorry, delivery to your desired address is unavailable”). Telegram will display this message to the user.
|
|
ErrorMessage string `json:"error_message,omitempty"`
|
|
}
|
|
|
|
// AnswerShippingQuery calls the answerShippingQuery Telegram Bot API method.
|
|
//
|
|
// If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
|
|
func AnswerShippingQuery(ctx context.Context, b *client.Bot, p *AnswerShippingQueryParams) (bool, error) {
|
|
return client.Call[*AnswerShippingQueryParams, bool](ctx, b, "answerShippingQuery", p)
|
|
}
|
|
|
|
// AnswerPreCheckoutQueryParams is the parameter set for AnswerPreCheckoutQuery.
|
|
//
|
|
// Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
|
|
type AnswerPreCheckoutQueryParams struct {
|
|
// Unique identifier for the query to be answered
|
|
PreCheckoutQueryID string `json:"pre_checkout_query_id"`
|
|
// Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
|
|
Ok bool `json:"ok"`
|
|
// Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.
|
|
ErrorMessage string `json:"error_message,omitempty"`
|
|
}
|
|
|
|
// AnswerPreCheckoutQuery calls the answerPreCheckoutQuery Telegram Bot API method.
|
|
//
|
|
// Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
|
|
func AnswerPreCheckoutQuery(ctx context.Context, b *client.Bot, p *AnswerPreCheckoutQueryParams) (bool, error) {
|
|
return client.Call[*AnswerPreCheckoutQueryParams, bool](ctx, b, "answerPreCheckoutQuery", p)
|
|
}
|
|
|
|
// GetMyStarBalanceParams is the parameter set for GetMyStarBalance.
|
|
//
|
|
// A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object.
|
|
type GetMyStarBalanceParams struct {
|
|
}
|
|
|
|
// GetMyStarBalance calls the getMyStarBalance Telegram Bot API method.
|
|
//
|
|
// A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object.
|
|
func GetMyStarBalance(ctx context.Context, b *client.Bot, p *GetMyStarBalanceParams) (*StarAmount, error) {
|
|
return client.Call[*GetMyStarBalanceParams, *StarAmount](ctx, b, "getMyStarBalance", p)
|
|
}
|
|
|
|
// GetStarTransactionsParams is the parameter set for GetStarTransactions.
|
|
//
|
|
// Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object.
|
|
type GetStarTransactionsParams struct {
|
|
// Number of transactions to skip in the response
|
|
Offset *int64 `json:"offset,omitempty"`
|
|
// The maximum number of transactions to be retrieved. Values between 1-100 are accepted. Defaults to 100.
|
|
Limit *int64 `json:"limit,omitempty"`
|
|
}
|
|
|
|
// GetStarTransactions calls the getStarTransactions Telegram Bot API method.
|
|
//
|
|
// Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object.
|
|
func GetStarTransactions(ctx context.Context, b *client.Bot, p *GetStarTransactionsParams) (*StarTransactions, error) {
|
|
return client.Call[*GetStarTransactionsParams, *StarTransactions](ctx, b, "getStarTransactions", p)
|
|
}
|
|
|
|
// RefundStarPaymentParams is the parameter set for RefundStarPayment.
|
|
//
|
|
// Refunds a successful payment in Telegram Stars. Returns True on success.
|
|
type RefundStarPaymentParams struct {
|
|
// Identifier of the user whose payment will be refunded
|
|
UserID int64 `json:"user_id"`
|
|
// Telegram payment identifier
|
|
TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
|
|
}
|
|
|
|
// RefundStarPayment calls the refundStarPayment Telegram Bot API method.
|
|
//
|
|
// Refunds a successful payment in Telegram Stars. Returns True on success.
|
|
func RefundStarPayment(ctx context.Context, b *client.Bot, p *RefundStarPaymentParams) (bool, error) {
|
|
return client.Call[*RefundStarPaymentParams, bool](ctx, b, "refundStarPayment", p)
|
|
}
|
|
|
|
// EditUserStarSubscriptionParams is the parameter set for EditUserStarSubscription.
|
|
//
|
|
// Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.
|
|
type EditUserStarSubscriptionParams struct {
|
|
// Identifier of the user whose subscription will be edited
|
|
UserID int64 `json:"user_id"`
|
|
// Telegram payment identifier for the subscription
|
|
TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
|
|
// Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot.
|
|
IsCanceled bool `json:"is_canceled"`
|
|
}
|
|
|
|
// EditUserStarSubscription calls the editUserStarSubscription Telegram Bot API method.
|
|
//
|
|
// Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.
|
|
func EditUserStarSubscription(ctx context.Context, b *client.Bot, p *EditUserStarSubscriptionParams) (bool, error) {
|
|
return client.Call[*EditUserStarSubscriptionParams, bool](ctx, b, "editUserStarSubscription", p)
|
|
}
|
|
|
|
// SetPassportDataErrorsParams is the parameter set for SetPassportDataErrors.
|
|
//
|
|
// Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
|
|
// Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.
|
|
type SetPassportDataErrorsParams struct {
|
|
// User identifier
|
|
UserID int64 `json:"user_id"`
|
|
// A JSON-serialized array describing the errors
|
|
Errors []PassportElementError `json:"errors"`
|
|
}
|
|
|
|
// SetPassportDataErrors calls the setPassportDataErrors Telegram Bot API method.
|
|
//
|
|
// Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
|
|
// Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.
|
|
func SetPassportDataErrors(ctx context.Context, b *client.Bot, p *SetPassportDataErrorsParams) (bool, error) {
|
|
return client.Call[*SetPassportDataErrorsParams, bool](ctx, b, "setPassportDataErrors", p)
|
|
}
|
|
|
|
// SendGameParams is the parameter set for SendGame.
|
|
//
|
|
// Use this method to send a game. On success, the sent Message is returned.
|
|
type SendGameParams struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
|
// Unique identifier for the target chat or username of the target bot in the format @username. Games can't be sent to channel direct messages chats and channel chats.
|
|
ChatID ChatID `json:"chat_id"`
|
|
// 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 *int64 `json:"message_thread_id,omitempty"`
|
|
// Short name of the game, serves as the unique identifier for the game. Set up your games via @BotFather.
|
|
GameShortName string `json:"game_short_name"`
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification *bool `json:"disable_notification,omitempty"`
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent *bool `json:"protect_content,omitempty"`
|
|
// 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"`
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectID string `json:"message_effect_id,omitempty"`
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"`
|
|
// A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
|
}
|
|
|
|
// SendGame calls the sendGame Telegram Bot API method.
|
|
//
|
|
// Use this method to send a game. On success, the sent Message is returned.
|
|
func SendGame(ctx context.Context, b *client.Bot, p *SendGameParams) (*Message, error) {
|
|
return client.Call[*SendGameParams, *Message](ctx, b, "sendGame", p)
|
|
}
|
|
|
|
// SetGameScoreParams is the parameter set for SetGameScore.
|
|
//
|
|
// Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
|
|
type SetGameScoreParams struct {
|
|
// User identifier
|
|
UserID int64 `json:"user_id"`
|
|
// New score, must be non-negative
|
|
Score int64 `json:"score"`
|
|
// Pass True if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters.
|
|
Force *bool `json:"force,omitempty"`
|
|
// Pass True if the game message should not be automatically edited to include the current scoreboard
|
|
DisableEditMessage *bool `json:"disable_edit_message,omitempty"`
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat.
|
|
ChatID *int64 `json:"chat_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Identifier of the sent message.
|
|
MessageID *int64 `json:"message_id,omitempty"`
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message.
|
|
InlineMessageID string `json:"inline_message_id,omitempty"`
|
|
}
|
|
|
|
// SetGameScore calls the setGameScore Telegram Bot API method.
|
|
//
|
|
// Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
|
|
func SetGameScore(ctx context.Context, b *client.Bot, p *SetGameScoreParams) (*MessageOrBool, error) {
|
|
return client.Call[*SetGameScoreParams, *MessageOrBool](ctx, b, "setGameScore", p)
|
|
}
|
|
|
|
// GetGameHighScoresParams is the parameter set for GetGameHighScores.
|
|
//
|
|
// Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects.
|
|
// This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change.
|
|
type GetGameHighScoresParams struct {
|
|
// Target user id
|
|
UserID int64 `json:"user_id"`
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat.
|
|
ChatID *int64 `json:"chat_id,omitempty"`
|
|
// Required if inline_message_id is not specified. Identifier of the sent message.
|
|
MessageID *int64 `json:"message_id,omitempty"`
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message.
|
|
InlineMessageID string `json:"inline_message_id,omitempty"`
|
|
}
|
|
|
|
// GetGameHighScores calls the getGameHighScores Telegram Bot API method.
|
|
//
|
|
// Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects.
|
|
// This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change.
|
|
func GetGameHighScores(ctx context.Context, b *client.Bot, p *GetGameHighScoresParams) ([]GameHighScore, error) {
|
|
return client.Call[*GetGameHighScoresParams, []GameHighScore](ctx, b, "getGameHighScores", p)
|
|
}
|