mirror of
https://github.com/crazy-max/diun.git
synced 2025-01-12 11:38:11 +00:00
64f77319b2
Bumps [github.com/PaulSonOfLars/gotgbot/v2](https://github.com/PaulSonOfLars/gotgbot) from 2.0.0-rc.27 to 2.0.0-rc.30. - [Release notes](https://github.com/PaulSonOfLars/gotgbot/releases) - [Commits](https://github.com/PaulSonOfLars/gotgbot/compare/v2.0.0-rc.27...v2.0.0-rc.30) --- updated-dependencies: - dependency-name: github.com/PaulSonOfLars/gotgbot/v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
6749 lines
301 KiB
Go
6749 lines
301 KiB
Go
// THIS FILE IS AUTOGENERATED. DO NOT EDIT.
|
|
// Regen by running 'go generate' in the repo root.
|
|
|
|
package gotgbot
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
)
|
|
|
|
// AddStickerToSetOpts is the set of optional fields for Bot.AddStickerToSet and Bot.AddStickerToSetWithContext.
|
|
type AddStickerToSetOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// AddStickerToSet (https://core.telegram.org/bots/api#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.
|
|
// - userId (type int64): User identifier of sticker set owner
|
|
// - name (type string): Sticker set name
|
|
// - sticker (type InputSticker): 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.
|
|
// - opts (type AddStickerToSetOpts): All optional parameters.
|
|
func (bot *Bot) AddStickerToSet(userId int64, name string, sticker InputSticker, opts *AddStickerToSetOpts) (bool, error) {
|
|
return bot.AddStickerToSetWithContext(context.Background(), userId, name, sticker, opts)
|
|
}
|
|
|
|
// AddStickerToSetWithContext is the same as Bot.AddStickerToSet, but with a context.Context parameter
|
|
func (bot *Bot) AddStickerToSetWithContext(ctx context.Context, userId int64, name string, sticker InputSticker, opts *AddStickerToSetOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
v["name"] = name
|
|
inputBs, err := sticker.InputParams("sticker", data)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field sticker: %w", err)
|
|
}
|
|
v["sticker"] = string(inputBs)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "addStickerToSet", v, data, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// AnswerCallbackQueryOpts is the set of optional fields for Bot.AnswerCallbackQuery and Bot.AnswerCallbackQueryWithContext.
|
|
type AnswerCallbackQueryOpts struct {
|
|
// Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
|
|
Text string
|
|
// 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
|
|
// 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
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// AnswerCallbackQuery (https://core.telegram.org/bots/api#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.
|
|
// - callbackQueryId (type string): Unique identifier for the query to be answered
|
|
// - opts (type AnswerCallbackQueryOpts): All optional parameters.
|
|
func (bot *Bot) AnswerCallbackQuery(callbackQueryId string, opts *AnswerCallbackQueryOpts) (bool, error) {
|
|
return bot.AnswerCallbackQueryWithContext(context.Background(), callbackQueryId, opts)
|
|
}
|
|
|
|
// AnswerCallbackQueryWithContext is the same as Bot.AnswerCallbackQuery, but with a context.Context parameter
|
|
func (bot *Bot) AnswerCallbackQueryWithContext(ctx context.Context, callbackQueryId string, opts *AnswerCallbackQueryOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["callback_query_id"] = callbackQueryId
|
|
if opts != nil {
|
|
v["text"] = opts.Text
|
|
v["show_alert"] = strconv.FormatBool(opts.ShowAlert)
|
|
v["url"] = opts.Url
|
|
if opts.CacheTime != 0 {
|
|
v["cache_time"] = strconv.FormatInt(opts.CacheTime, 10)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "answerCallbackQuery", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// AnswerInlineQueryOpts is the set of optional fields for Bot.AnswerInlineQuery and Bot.AnswerInlineQueryWithContext.
|
|
type AnswerInlineQueryOpts struct {
|
|
// 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
|
|
// 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
|
|
// 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
|
|
// A JSON-serialized object describing a button to be shown above inline query results
|
|
Button *InlineQueryResultsButton
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// AnswerInlineQuery (https://core.telegram.org/bots/api#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.
|
|
// - inlineQueryId (type string): Unique identifier for the answered query
|
|
// - results (type []InlineQueryResult): A JSON-serialized array of results for the inline query
|
|
// - opts (type AnswerInlineQueryOpts): All optional parameters.
|
|
func (bot *Bot) AnswerInlineQuery(inlineQueryId string, results []InlineQueryResult, opts *AnswerInlineQueryOpts) (bool, error) {
|
|
return bot.AnswerInlineQueryWithContext(context.Background(), inlineQueryId, results, opts)
|
|
}
|
|
|
|
// AnswerInlineQueryWithContext is the same as Bot.AnswerInlineQuery, but with a context.Context parameter
|
|
func (bot *Bot) AnswerInlineQueryWithContext(ctx context.Context, inlineQueryId string, results []InlineQueryResult, opts *AnswerInlineQueryOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["inline_query_id"] = inlineQueryId
|
|
if results != nil {
|
|
bs, err := json.Marshal(results)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field results: %w", err)
|
|
}
|
|
v["results"] = string(bs)
|
|
}
|
|
if opts != nil {
|
|
if opts.CacheTime != 0 {
|
|
v["cache_time"] = strconv.FormatInt(opts.CacheTime, 10)
|
|
}
|
|
v["is_personal"] = strconv.FormatBool(opts.IsPersonal)
|
|
v["next_offset"] = opts.NextOffset
|
|
if opts.Button != nil {
|
|
bs, err := json.Marshal(opts.Button)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field button: %w", err)
|
|
}
|
|
v["button"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "answerInlineQuery", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// AnswerPreCheckoutQueryOpts is the set of optional fields for Bot.AnswerPreCheckoutQuery and Bot.AnswerPreCheckoutQueryWithContext.
|
|
type AnswerPreCheckoutQueryOpts struct {
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// AnswerPreCheckoutQuery (https://core.telegram.org/bots/api#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.
|
|
// - preCheckoutQueryId (type string): Unique identifier for the query to be answered
|
|
// - ok (type bool): 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.
|
|
// - opts (type AnswerPreCheckoutQueryOpts): All optional parameters.
|
|
func (bot *Bot) AnswerPreCheckoutQuery(preCheckoutQueryId string, ok bool, opts *AnswerPreCheckoutQueryOpts) (bool, error) {
|
|
return bot.AnswerPreCheckoutQueryWithContext(context.Background(), preCheckoutQueryId, ok, opts)
|
|
}
|
|
|
|
// AnswerPreCheckoutQueryWithContext is the same as Bot.AnswerPreCheckoutQuery, but with a context.Context parameter
|
|
func (bot *Bot) AnswerPreCheckoutQueryWithContext(ctx context.Context, preCheckoutQueryId string, ok bool, opts *AnswerPreCheckoutQueryOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["pre_checkout_query_id"] = preCheckoutQueryId
|
|
v["ok"] = strconv.FormatBool(ok)
|
|
if opts != nil {
|
|
v["error_message"] = opts.ErrorMessage
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "answerPreCheckoutQuery", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// AnswerShippingQueryOpts is the set of optional fields for Bot.AnswerShippingQuery and Bot.AnswerShippingQueryWithContext.
|
|
type AnswerShippingQueryOpts struct {
|
|
// Required if ok is True. A JSON-serialized array of available shipping options.
|
|
ShippingOptions []ShippingOption
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// AnswerShippingQuery (https://core.telegram.org/bots/api#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.
|
|
// - shippingQueryId (type string): Unique identifier for the query to be answered
|
|
// - ok (type bool): 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)
|
|
// - opts (type AnswerShippingQueryOpts): All optional parameters.
|
|
func (bot *Bot) AnswerShippingQuery(shippingQueryId string, ok bool, opts *AnswerShippingQueryOpts) (bool, error) {
|
|
return bot.AnswerShippingQueryWithContext(context.Background(), shippingQueryId, ok, opts)
|
|
}
|
|
|
|
// AnswerShippingQueryWithContext is the same as Bot.AnswerShippingQuery, but with a context.Context parameter
|
|
func (bot *Bot) AnswerShippingQueryWithContext(ctx context.Context, shippingQueryId string, ok bool, opts *AnswerShippingQueryOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["shipping_query_id"] = shippingQueryId
|
|
v["ok"] = strconv.FormatBool(ok)
|
|
if opts != nil {
|
|
if opts.ShippingOptions != nil {
|
|
bs, err := json.Marshal(opts.ShippingOptions)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field shipping_options: %w", err)
|
|
}
|
|
v["shipping_options"] = string(bs)
|
|
}
|
|
v["error_message"] = opts.ErrorMessage
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "answerShippingQuery", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// AnswerWebAppQueryOpts is the set of optional fields for Bot.AnswerWebAppQuery and Bot.AnswerWebAppQueryWithContext.
|
|
type AnswerWebAppQueryOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// AnswerWebAppQuery (https://core.telegram.org/bots/api#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.
|
|
// - webAppQueryId (type string): Unique identifier for the query to be answered
|
|
// - result (type InlineQueryResult): A JSON-serialized object describing the message to be sent
|
|
// - opts (type AnswerWebAppQueryOpts): All optional parameters.
|
|
func (bot *Bot) AnswerWebAppQuery(webAppQueryId string, result InlineQueryResult, opts *AnswerWebAppQueryOpts) (*SentWebAppMessage, error) {
|
|
return bot.AnswerWebAppQueryWithContext(context.Background(), webAppQueryId, result, opts)
|
|
}
|
|
|
|
// AnswerWebAppQueryWithContext is the same as Bot.AnswerWebAppQuery, but with a context.Context parameter
|
|
func (bot *Bot) AnswerWebAppQueryWithContext(ctx context.Context, webAppQueryId string, result InlineQueryResult, opts *AnswerWebAppQueryOpts) (*SentWebAppMessage, error) {
|
|
v := map[string]string{}
|
|
v["web_app_query_id"] = webAppQueryId
|
|
bs, err := json.Marshal(result)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field result: %w", err)
|
|
}
|
|
v["result"] = string(bs)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "answerWebAppQuery", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var s SentWebAppMessage
|
|
return &s, json.Unmarshal(r, &s)
|
|
}
|
|
|
|
// ApproveChatJoinRequestOpts is the set of optional fields for Bot.ApproveChatJoinRequest and Bot.ApproveChatJoinRequestWithContext.
|
|
type ApproveChatJoinRequestOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// ApproveChatJoinRequest (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - userId (type int64): Unique identifier of the target user
|
|
// - opts (type ApproveChatJoinRequestOpts): All optional parameters.
|
|
func (bot *Bot) ApproveChatJoinRequest(chatId int64, userId int64, opts *ApproveChatJoinRequestOpts) (bool, error) {
|
|
return bot.ApproveChatJoinRequestWithContext(context.Background(), chatId, userId, opts)
|
|
}
|
|
|
|
// ApproveChatJoinRequestWithContext is the same as Bot.ApproveChatJoinRequest, but with a context.Context parameter
|
|
func (bot *Bot) ApproveChatJoinRequestWithContext(ctx context.Context, chatId int64, userId int64, opts *ApproveChatJoinRequestOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "approveChatJoinRequest", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// BanChatMemberOpts is the set of optional fields for Bot.BanChatMember and Bot.BanChatMemberWithContext.
|
|
type BanChatMemberOpts struct {
|
|
// 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
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// BanChatMember (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target group
|
|
// - userId (type int64): Unique identifier of the target user
|
|
// - opts (type BanChatMemberOpts): All optional parameters.
|
|
func (bot *Bot) BanChatMember(chatId int64, userId int64, opts *BanChatMemberOpts) (bool, error) {
|
|
return bot.BanChatMemberWithContext(context.Background(), chatId, userId, opts)
|
|
}
|
|
|
|
// BanChatMemberWithContext is the same as Bot.BanChatMember, but with a context.Context parameter
|
|
func (bot *Bot) BanChatMemberWithContext(ctx context.Context, chatId int64, userId int64, opts *BanChatMemberOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
if opts != nil {
|
|
if opts.UntilDate != 0 {
|
|
v["until_date"] = strconv.FormatInt(opts.UntilDate, 10)
|
|
}
|
|
v["revoke_messages"] = strconv.FormatBool(opts.RevokeMessages)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "banChatMember", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// BanChatSenderChatOpts is the set of optional fields for Bot.BanChatSenderChat and Bot.BanChatSenderChatWithContext.
|
|
type BanChatSenderChatOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// BanChatSenderChat (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - senderChatId (type int64): Unique identifier of the target sender chat
|
|
// - opts (type BanChatSenderChatOpts): All optional parameters.
|
|
func (bot *Bot) BanChatSenderChat(chatId int64, senderChatId int64, opts *BanChatSenderChatOpts) (bool, error) {
|
|
return bot.BanChatSenderChatWithContext(context.Background(), chatId, senderChatId, opts)
|
|
}
|
|
|
|
// BanChatSenderChatWithContext is the same as Bot.BanChatSenderChat, but with a context.Context parameter
|
|
func (bot *Bot) BanChatSenderChatWithContext(ctx context.Context, chatId int64, senderChatId int64, opts *BanChatSenderChatOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["sender_chat_id"] = strconv.FormatInt(senderChatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "banChatSenderChat", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// CloseOpts is the set of optional fields for Bot.Close and Bot.CloseWithContext.
|
|
type CloseOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// Close (https://core.telegram.org/bots/api#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.
|
|
// - opts (type CloseOpts): All optional parameters.
|
|
func (bot *Bot) Close(opts *CloseOpts) (bool, error) {
|
|
return bot.CloseWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// CloseWithContext is the same as Bot.Close, but with a context.Context parameter
|
|
func (bot *Bot) CloseWithContext(ctx context.Context, opts *CloseOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "close", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// CloseForumTopicOpts is the set of optional fields for Bot.CloseForumTopic and Bot.CloseForumTopicWithContext.
|
|
type CloseForumTopicOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// CloseForumTopic (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - messageThreadId (type int64): Unique identifier for the target message thread of the forum topic
|
|
// - opts (type CloseForumTopicOpts): All optional parameters.
|
|
func (bot *Bot) CloseForumTopic(chatId int64, messageThreadId int64, opts *CloseForumTopicOpts) (bool, error) {
|
|
return bot.CloseForumTopicWithContext(context.Background(), chatId, messageThreadId, opts)
|
|
}
|
|
|
|
// CloseForumTopicWithContext is the same as Bot.CloseForumTopic, but with a context.Context parameter
|
|
func (bot *Bot) CloseForumTopicWithContext(ctx context.Context, chatId int64, messageThreadId int64, opts *CloseForumTopicOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["message_thread_id"] = strconv.FormatInt(messageThreadId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "closeForumTopic", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// CloseGeneralForumTopicOpts is the set of optional fields for Bot.CloseGeneralForumTopic and Bot.CloseGeneralForumTopicWithContext.
|
|
type CloseGeneralForumTopicOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// CloseGeneralForumTopic (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type CloseGeneralForumTopicOpts): All optional parameters.
|
|
func (bot *Bot) CloseGeneralForumTopic(chatId int64, opts *CloseGeneralForumTopicOpts) (bool, error) {
|
|
return bot.CloseGeneralForumTopicWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// CloseGeneralForumTopicWithContext is the same as Bot.CloseGeneralForumTopic, but with a context.Context parameter
|
|
func (bot *Bot) CloseGeneralForumTopicWithContext(ctx context.Context, chatId int64, opts *CloseGeneralForumTopicOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "closeGeneralForumTopic", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// CopyMessageOpts is the set of optional fields for Bot.CopyMessage and Bot.CopyMessageWithContext.
|
|
type CopyMessageOpts struct {
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
|
|
Caption *string
|
|
// Mode for parsing entities in the new caption. See formatting options for more details.
|
|
ParseMode string
|
|
// A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of parse_mode
|
|
CaptionEntities []MessageEntity
|
|
// Pass True, if the caption must be shown above the message media. Ignored if a new caption isn't specified.
|
|
ShowCaptionAboveMedia bool
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// CopyMessage (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - fromChatId (type int64): Unique identifier for the chat where the original message was sent
|
|
// - messageId (type int64): Message identifier in the chat specified in from_chat_id
|
|
// - opts (type CopyMessageOpts): All optional parameters.
|
|
func (bot *Bot) CopyMessage(chatId int64, fromChatId int64, messageId int64, opts *CopyMessageOpts) (*MessageId, error) {
|
|
return bot.CopyMessageWithContext(context.Background(), chatId, fromChatId, messageId, opts)
|
|
}
|
|
|
|
// CopyMessageWithContext is the same as Bot.CopyMessage, but with a context.Context parameter
|
|
func (bot *Bot) CopyMessageWithContext(ctx context.Context, chatId int64, fromChatId int64, messageId int64, opts *CopyMessageOpts) (*MessageId, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["from_chat_id"] = strconv.FormatInt(fromChatId, 10)
|
|
v["message_id"] = strconv.FormatInt(messageId, 10)
|
|
if opts != nil {
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
if opts.Caption != nil {
|
|
v["caption"] = *opts.Caption
|
|
}
|
|
v["parse_mode"] = opts.ParseMode
|
|
if opts.CaptionEntities != nil {
|
|
bs, err := json.Marshal(opts.CaptionEntities)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err)
|
|
}
|
|
v["caption_entities"] = string(bs)
|
|
}
|
|
v["show_caption_above_media"] = strconv.FormatBool(opts.ShowCaptionAboveMedia)
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "copyMessage", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m MessageId
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// CopyMessagesOpts is the set of optional fields for Bot.CopyMessages and Bot.CopyMessagesWithContext.
|
|
type CopyMessagesOpts struct {
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Sends the messages silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent messages from forwarding and saving
|
|
ProtectContent bool
|
|
// Pass True to copy the messages without their captions
|
|
RemoveCaption bool
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// CopyMessages (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - fromChatId (type int64): Unique identifier for the chat where the original messages were sent
|
|
// - messageIds (type []int64): 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.
|
|
// - opts (type CopyMessagesOpts): All optional parameters.
|
|
func (bot *Bot) CopyMessages(chatId int64, fromChatId int64, messageIds []int64, opts *CopyMessagesOpts) ([]MessageId, error) {
|
|
return bot.CopyMessagesWithContext(context.Background(), chatId, fromChatId, messageIds, opts)
|
|
}
|
|
|
|
// CopyMessagesWithContext is the same as Bot.CopyMessages, but with a context.Context parameter
|
|
func (bot *Bot) CopyMessagesWithContext(ctx context.Context, chatId int64, fromChatId int64, messageIds []int64, opts *CopyMessagesOpts) ([]MessageId, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["from_chat_id"] = strconv.FormatInt(fromChatId, 10)
|
|
if messageIds != nil {
|
|
bs, err := json.Marshal(messageIds)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field message_ids: %w", err)
|
|
}
|
|
v["message_ids"] = string(bs)
|
|
}
|
|
if opts != nil {
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["remove_caption"] = strconv.FormatBool(opts.RemoveCaption)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "copyMessages", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m []MessageId
|
|
return m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// CreateChatInviteLinkOpts is the set of optional fields for Bot.CreateChatInviteLink and Bot.CreateChatInviteLinkWithContext.
|
|
type CreateChatInviteLinkOpts struct {
|
|
// Invite link name; 0-32 characters
|
|
Name string
|
|
// Point in time (Unix timestamp) when the link will expire
|
|
ExpireDate int64
|
|
// 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
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// CreateChatInviteLink (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type CreateChatInviteLinkOpts): All optional parameters.
|
|
func (bot *Bot) CreateChatInviteLink(chatId int64, opts *CreateChatInviteLinkOpts) (*ChatInviteLink, error) {
|
|
return bot.CreateChatInviteLinkWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// CreateChatInviteLinkWithContext is the same as Bot.CreateChatInviteLink, but with a context.Context parameter
|
|
func (bot *Bot) CreateChatInviteLinkWithContext(ctx context.Context, chatId int64, opts *CreateChatInviteLinkOpts) (*ChatInviteLink, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if opts != nil {
|
|
v["name"] = opts.Name
|
|
if opts.ExpireDate != 0 {
|
|
v["expire_date"] = strconv.FormatInt(opts.ExpireDate, 10)
|
|
}
|
|
if opts.MemberLimit != 0 {
|
|
v["member_limit"] = strconv.FormatInt(opts.MemberLimit, 10)
|
|
}
|
|
v["creates_join_request"] = strconv.FormatBool(opts.CreatesJoinRequest)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "createChatInviteLink", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var c ChatInviteLink
|
|
return &c, json.Unmarshal(r, &c)
|
|
}
|
|
|
|
// CreateChatSubscriptionInviteLinkOpts is the set of optional fields for Bot.CreateChatSubscriptionInviteLink and Bot.CreateChatSubscriptionInviteLinkWithContext.
|
|
type CreateChatSubscriptionInviteLinkOpts struct {
|
|
// Invite link name; 0-32 characters
|
|
Name string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// CreateChatSubscriptionInviteLink (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target channel chat
|
|
// - subscriptionPeriod (type int64): The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
|
|
// - subscriptionPrice (type int64): The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
|
|
// - opts (type CreateChatSubscriptionInviteLinkOpts): All optional parameters.
|
|
func (bot *Bot) CreateChatSubscriptionInviteLink(chatId int64, subscriptionPeriod int64, subscriptionPrice int64, opts *CreateChatSubscriptionInviteLinkOpts) (*ChatInviteLink, error) {
|
|
return bot.CreateChatSubscriptionInviteLinkWithContext(context.Background(), chatId, subscriptionPeriod, subscriptionPrice, opts)
|
|
}
|
|
|
|
// CreateChatSubscriptionInviteLinkWithContext is the same as Bot.CreateChatSubscriptionInviteLink, but with a context.Context parameter
|
|
func (bot *Bot) CreateChatSubscriptionInviteLinkWithContext(ctx context.Context, chatId int64, subscriptionPeriod int64, subscriptionPrice int64, opts *CreateChatSubscriptionInviteLinkOpts) (*ChatInviteLink, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["subscription_period"] = strconv.FormatInt(subscriptionPeriod, 10)
|
|
v["subscription_price"] = strconv.FormatInt(subscriptionPrice, 10)
|
|
if opts != nil {
|
|
v["name"] = opts.Name
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "createChatSubscriptionInviteLink", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var c ChatInviteLink
|
|
return &c, json.Unmarshal(r, &c)
|
|
}
|
|
|
|
// CreateForumTopicOpts is the set of optional fields for Bot.CreateForumTopic and Bot.CreateForumTopicWithContext.
|
|
type CreateForumTopicOpts struct {
|
|
// 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
|
|
// Unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.
|
|
IconCustomEmojiId string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// CreateForumTopic (https://core.telegram.org/bots/api#createforumtopic)
|
|
//
|
|
// Use this method to create a 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 information about the created topic as a ForumTopic object.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - name (type string): Topic name, 1-128 characters
|
|
// - opts (type CreateForumTopicOpts): All optional parameters.
|
|
func (bot *Bot) CreateForumTopic(chatId int64, name string, opts *CreateForumTopicOpts) (*ForumTopic, error) {
|
|
return bot.CreateForumTopicWithContext(context.Background(), chatId, name, opts)
|
|
}
|
|
|
|
// CreateForumTopicWithContext is the same as Bot.CreateForumTopic, but with a context.Context parameter
|
|
func (bot *Bot) CreateForumTopicWithContext(ctx context.Context, chatId int64, name string, opts *CreateForumTopicOpts) (*ForumTopic, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["name"] = name
|
|
if opts != nil {
|
|
if opts.IconColor != 0 {
|
|
v["icon_color"] = strconv.FormatInt(opts.IconColor, 10)
|
|
}
|
|
v["icon_custom_emoji_id"] = opts.IconCustomEmojiId
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "createForumTopic", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var f ForumTopic
|
|
return &f, json.Unmarshal(r, &f)
|
|
}
|
|
|
|
// CreateInvoiceLinkOpts is the set of optional fields for Bot.CreateInvoiceLink and Bot.CreateInvoiceLinkWithContext.
|
|
type CreateInvoiceLinkOpts struct {
|
|
// Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
|
|
ProviderToken string
|
|
// 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
|
|
// 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-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
|
|
// URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.
|
|
PhotoUrl string
|
|
// Photo size in bytes
|
|
PhotoSize int64
|
|
// Photo width
|
|
PhotoWidth int64
|
|
// Photo height
|
|
PhotoHeight int64
|
|
// Pass True if you require the user's full name to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedName bool
|
|
// Pass True if you require the user's phone number to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedPhoneNumber bool
|
|
// Pass True if you require the user's email address to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedEmail bool
|
|
// Pass True if you require the user's shipping address to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedShippingAddress bool
|
|
// Pass True if the user's phone number should be sent to the provider. Ignored for payments in Telegram Stars.
|
|
SendPhoneNumberToProvider bool
|
|
// Pass True if the user's email address should be sent to the provider. Ignored for payments in Telegram Stars.
|
|
SendEmailToProvider bool
|
|
// Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars.
|
|
IsFlexible bool
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// CreateInvoiceLink (https://core.telegram.org/bots/api#createinvoicelink)
|
|
//
|
|
// Use this method to create a link for an invoice. Returns the created invoice link as String on success.
|
|
// - title (type string): Product name, 1-32 characters
|
|
// - description (type string): Product description, 1-255 characters
|
|
// - payload (type string): Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
|
|
// - currency (type string): Three-letter ISO 4217 currency code, see more on currencies. Pass "XTR" for payments in Telegram Stars.
|
|
// - prices (type []LabeledPrice): 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.
|
|
// - opts (type CreateInvoiceLinkOpts): All optional parameters.
|
|
func (bot *Bot) CreateInvoiceLink(title string, description string, payload string, currency string, prices []LabeledPrice, opts *CreateInvoiceLinkOpts) (string, error) {
|
|
return bot.CreateInvoiceLinkWithContext(context.Background(), title, description, payload, currency, prices, opts)
|
|
}
|
|
|
|
// CreateInvoiceLinkWithContext is the same as Bot.CreateInvoiceLink, but with a context.Context parameter
|
|
func (bot *Bot) CreateInvoiceLinkWithContext(ctx context.Context, title string, description string, payload string, currency string, prices []LabeledPrice, opts *CreateInvoiceLinkOpts) (string, error) {
|
|
v := map[string]string{}
|
|
v["title"] = title
|
|
v["description"] = description
|
|
v["payload"] = payload
|
|
v["currency"] = currency
|
|
if prices != nil {
|
|
bs, err := json.Marshal(prices)
|
|
if err != nil {
|
|
return "", fmt.Errorf("failed to marshal field prices: %w", err)
|
|
}
|
|
v["prices"] = string(bs)
|
|
}
|
|
if opts != nil {
|
|
v["provider_token"] = opts.ProviderToken
|
|
if opts.MaxTipAmount != 0 {
|
|
v["max_tip_amount"] = strconv.FormatInt(opts.MaxTipAmount, 10)
|
|
}
|
|
if opts.SuggestedTipAmounts != nil {
|
|
bs, err := json.Marshal(opts.SuggestedTipAmounts)
|
|
if err != nil {
|
|
return "", fmt.Errorf("failed to marshal field suggested_tip_amounts: %w", err)
|
|
}
|
|
v["suggested_tip_amounts"] = string(bs)
|
|
}
|
|
v["provider_data"] = opts.ProviderData
|
|
v["photo_url"] = opts.PhotoUrl
|
|
if opts.PhotoSize != 0 {
|
|
v["photo_size"] = strconv.FormatInt(opts.PhotoSize, 10)
|
|
}
|
|
if opts.PhotoWidth != 0 {
|
|
v["photo_width"] = strconv.FormatInt(opts.PhotoWidth, 10)
|
|
}
|
|
if opts.PhotoHeight != 0 {
|
|
v["photo_height"] = strconv.FormatInt(opts.PhotoHeight, 10)
|
|
}
|
|
v["need_name"] = strconv.FormatBool(opts.NeedName)
|
|
v["need_phone_number"] = strconv.FormatBool(opts.NeedPhoneNumber)
|
|
v["need_email"] = strconv.FormatBool(opts.NeedEmail)
|
|
v["need_shipping_address"] = strconv.FormatBool(opts.NeedShippingAddress)
|
|
v["send_phone_number_to_provider"] = strconv.FormatBool(opts.SendPhoneNumberToProvider)
|
|
v["send_email_to_provider"] = strconv.FormatBool(opts.SendEmailToProvider)
|
|
v["is_flexible"] = strconv.FormatBool(opts.IsFlexible)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "createInvoiceLink", v, nil, reqOpts)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
var s string
|
|
return s, json.Unmarshal(r, &s)
|
|
}
|
|
|
|
// CreateNewStickerSetOpts is the set of optional fields for Bot.CreateNewStickerSet and Bot.CreateNewStickerSetWithContext.
|
|
type CreateNewStickerSetOpts struct {
|
|
// Type of stickers in the set, pass "regular", "mask", or "custom_emoji". By default, a regular sticker set is created.
|
|
StickerType string
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// CreateNewStickerSet (https://core.telegram.org/bots/api#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.
|
|
// - userId (type int64): User identifier of created sticker set owner
|
|
// - name (type string): 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.
|
|
// - title (type string): Sticker set title, 1-64 characters
|
|
// - stickers (type []InputSticker): A JSON-serialized list of 1-50 initial stickers to be added to the sticker set
|
|
// - opts (type CreateNewStickerSetOpts): All optional parameters.
|
|
func (bot *Bot) CreateNewStickerSet(userId int64, name string, title string, stickers []InputSticker, opts *CreateNewStickerSetOpts) (bool, error) {
|
|
return bot.CreateNewStickerSetWithContext(context.Background(), userId, name, title, stickers, opts)
|
|
}
|
|
|
|
// CreateNewStickerSetWithContext is the same as Bot.CreateNewStickerSet, but with a context.Context parameter
|
|
func (bot *Bot) CreateNewStickerSetWithContext(ctx context.Context, userId int64, name string, title string, stickers []InputSticker, opts *CreateNewStickerSetOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
v["name"] = name
|
|
v["title"] = title
|
|
if stickers != nil {
|
|
var rawList []json.RawMessage
|
|
for idx, im := range stickers {
|
|
inputBs, err := im.InputParams("stickers"+strconv.Itoa(idx), data)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal list item %d for field stickers: %w", idx, err)
|
|
}
|
|
rawList = append(rawList, inputBs)
|
|
}
|
|
bs, err := json.Marshal(rawList)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal raw json list for field: stickers %w", err)
|
|
}
|
|
v["stickers"] = string(bs)
|
|
}
|
|
if opts != nil {
|
|
v["sticker_type"] = opts.StickerType
|
|
v["needs_repainting"] = strconv.FormatBool(opts.NeedsRepainting)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "createNewStickerSet", v, data, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// DeclineChatJoinRequestOpts is the set of optional fields for Bot.DeclineChatJoinRequest and Bot.DeclineChatJoinRequestWithContext.
|
|
type DeclineChatJoinRequestOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// DeclineChatJoinRequest (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - userId (type int64): Unique identifier of the target user
|
|
// - opts (type DeclineChatJoinRequestOpts): All optional parameters.
|
|
func (bot *Bot) DeclineChatJoinRequest(chatId int64, userId int64, opts *DeclineChatJoinRequestOpts) (bool, error) {
|
|
return bot.DeclineChatJoinRequestWithContext(context.Background(), chatId, userId, opts)
|
|
}
|
|
|
|
// DeclineChatJoinRequestWithContext is the same as Bot.DeclineChatJoinRequest, but with a context.Context parameter
|
|
func (bot *Bot) DeclineChatJoinRequestWithContext(ctx context.Context, chatId int64, userId int64, opts *DeclineChatJoinRequestOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "declineChatJoinRequest", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// DeleteChatPhotoOpts is the set of optional fields for Bot.DeleteChatPhoto and Bot.DeleteChatPhotoWithContext.
|
|
type DeleteChatPhotoOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// DeleteChatPhoto (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type DeleteChatPhotoOpts): All optional parameters.
|
|
func (bot *Bot) DeleteChatPhoto(chatId int64, opts *DeleteChatPhotoOpts) (bool, error) {
|
|
return bot.DeleteChatPhotoWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// DeleteChatPhotoWithContext is the same as Bot.DeleteChatPhoto, but with a context.Context parameter
|
|
func (bot *Bot) DeleteChatPhotoWithContext(ctx context.Context, chatId int64, opts *DeleteChatPhotoOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "deleteChatPhoto", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// DeleteChatStickerSetOpts is the set of optional fields for Bot.DeleteChatStickerSet and Bot.DeleteChatStickerSetWithContext.
|
|
type DeleteChatStickerSetOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// DeleteChatStickerSet (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type DeleteChatStickerSetOpts): All optional parameters.
|
|
func (bot *Bot) DeleteChatStickerSet(chatId int64, opts *DeleteChatStickerSetOpts) (bool, error) {
|
|
return bot.DeleteChatStickerSetWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// DeleteChatStickerSetWithContext is the same as Bot.DeleteChatStickerSet, but with a context.Context parameter
|
|
func (bot *Bot) DeleteChatStickerSetWithContext(ctx context.Context, chatId int64, opts *DeleteChatStickerSetOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "deleteChatStickerSet", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// DeleteForumTopicOpts is the set of optional fields for Bot.DeleteForumTopic and Bot.DeleteForumTopicWithContext.
|
|
type DeleteForumTopicOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// DeleteForumTopic (https://core.telegram.org/bots/api#deleteforumtopic)
|
|
//
|
|
// Use this method to delete a forum topic along with all its messages in a forum 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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - messageThreadId (type int64): Unique identifier for the target message thread of the forum topic
|
|
// - opts (type DeleteForumTopicOpts): All optional parameters.
|
|
func (bot *Bot) DeleteForumTopic(chatId int64, messageThreadId int64, opts *DeleteForumTopicOpts) (bool, error) {
|
|
return bot.DeleteForumTopicWithContext(context.Background(), chatId, messageThreadId, opts)
|
|
}
|
|
|
|
// DeleteForumTopicWithContext is the same as Bot.DeleteForumTopic, but with a context.Context parameter
|
|
func (bot *Bot) DeleteForumTopicWithContext(ctx context.Context, chatId int64, messageThreadId int64, opts *DeleteForumTopicOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["message_thread_id"] = strconv.FormatInt(messageThreadId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "deleteForumTopic", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// DeleteMessageOpts is the set of optional fields for Bot.DeleteMessage and Bot.DeleteMessageWithContext.
|
|
type DeleteMessageOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// DeleteMessage (https://core.telegram.org/bots/api#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 permission in a supergroup or a channel, it can delete any message there.
|
|
//
|
|
// Returns True on success.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - messageId (type int64): Identifier of the message to delete
|
|
// - opts (type DeleteMessageOpts): All optional parameters.
|
|
func (bot *Bot) DeleteMessage(chatId int64, messageId int64, opts *DeleteMessageOpts) (bool, error) {
|
|
return bot.DeleteMessageWithContext(context.Background(), chatId, messageId, opts)
|
|
}
|
|
|
|
// DeleteMessageWithContext is the same as Bot.DeleteMessage, but with a context.Context parameter
|
|
func (bot *Bot) DeleteMessageWithContext(ctx context.Context, chatId int64, messageId int64, opts *DeleteMessageOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["message_id"] = strconv.FormatInt(messageId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "deleteMessage", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// DeleteMessagesOpts is the set of optional fields for Bot.DeleteMessages and Bot.DeleteMessagesWithContext.
|
|
type DeleteMessagesOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// DeleteMessages (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - messageIds (type []int64): A JSON-serialized list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted
|
|
// - opts (type DeleteMessagesOpts): All optional parameters.
|
|
func (bot *Bot) DeleteMessages(chatId int64, messageIds []int64, opts *DeleteMessagesOpts) (bool, error) {
|
|
return bot.DeleteMessagesWithContext(context.Background(), chatId, messageIds, opts)
|
|
}
|
|
|
|
// DeleteMessagesWithContext is the same as Bot.DeleteMessages, but with a context.Context parameter
|
|
func (bot *Bot) DeleteMessagesWithContext(ctx context.Context, chatId int64, messageIds []int64, opts *DeleteMessagesOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if messageIds != nil {
|
|
bs, err := json.Marshal(messageIds)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field message_ids: %w", err)
|
|
}
|
|
v["message_ids"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "deleteMessages", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// DeleteMyCommandsOpts is the set of optional fields for Bot.DeleteMyCommands and Bot.DeleteMyCommandsWithContext.
|
|
type DeleteMyCommandsOpts struct {
|
|
// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
|
|
Scope BotCommandScope
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// DeleteMyCommands (https://core.telegram.org/bots/api#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.
|
|
// - opts (type DeleteMyCommandsOpts): All optional parameters.
|
|
func (bot *Bot) DeleteMyCommands(opts *DeleteMyCommandsOpts) (bool, error) {
|
|
return bot.DeleteMyCommandsWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// DeleteMyCommandsWithContext is the same as Bot.DeleteMyCommands, but with a context.Context parameter
|
|
func (bot *Bot) DeleteMyCommandsWithContext(ctx context.Context, opts *DeleteMyCommandsOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
bs, err := json.Marshal(opts.Scope)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field scope: %w", err)
|
|
}
|
|
v["scope"] = string(bs)
|
|
v["language_code"] = opts.LanguageCode
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "deleteMyCommands", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// DeleteStickerFromSetOpts is the set of optional fields for Bot.DeleteStickerFromSet and Bot.DeleteStickerFromSetWithContext.
|
|
type DeleteStickerFromSetOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// DeleteStickerFromSet (https://core.telegram.org/bots/api#deletestickerfromset)
|
|
//
|
|
// Use this method to delete a sticker from a set created by the bot. Returns True on success.
|
|
// - sticker (type string): File identifier of the sticker
|
|
// - opts (type DeleteStickerFromSetOpts): All optional parameters.
|
|
func (bot *Bot) DeleteStickerFromSet(sticker string, opts *DeleteStickerFromSetOpts) (bool, error) {
|
|
return bot.DeleteStickerFromSetWithContext(context.Background(), sticker, opts)
|
|
}
|
|
|
|
// DeleteStickerFromSetWithContext is the same as Bot.DeleteStickerFromSet, but with a context.Context parameter
|
|
func (bot *Bot) DeleteStickerFromSetWithContext(ctx context.Context, sticker string, opts *DeleteStickerFromSetOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["sticker"] = sticker
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "deleteStickerFromSet", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// DeleteStickerSetOpts is the set of optional fields for Bot.DeleteStickerSet and Bot.DeleteStickerSetWithContext.
|
|
type DeleteStickerSetOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// DeleteStickerSet (https://core.telegram.org/bots/api#deletestickerset)
|
|
//
|
|
// Use this method to delete a sticker set that was created by the bot. Returns True on success.
|
|
// - name (type string): Sticker set name
|
|
// - opts (type DeleteStickerSetOpts): All optional parameters.
|
|
func (bot *Bot) DeleteStickerSet(name string, opts *DeleteStickerSetOpts) (bool, error) {
|
|
return bot.DeleteStickerSetWithContext(context.Background(), name, opts)
|
|
}
|
|
|
|
// DeleteStickerSetWithContext is the same as Bot.DeleteStickerSet, but with a context.Context parameter
|
|
func (bot *Bot) DeleteStickerSetWithContext(ctx context.Context, name string, opts *DeleteStickerSetOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["name"] = name
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "deleteStickerSet", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// DeleteWebhookOpts is the set of optional fields for Bot.DeleteWebhook and Bot.DeleteWebhookWithContext.
|
|
type DeleteWebhookOpts struct {
|
|
// Pass True to drop all pending updates
|
|
DropPendingUpdates bool
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// DeleteWebhook (https://core.telegram.org/bots/api#deletewebhook)
|
|
//
|
|
// Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success.
|
|
// - opts (type DeleteWebhookOpts): All optional parameters.
|
|
func (bot *Bot) DeleteWebhook(opts *DeleteWebhookOpts) (bool, error) {
|
|
return bot.DeleteWebhookWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// DeleteWebhookWithContext is the same as Bot.DeleteWebhook, but with a context.Context parameter
|
|
func (bot *Bot) DeleteWebhookWithContext(ctx context.Context, opts *DeleteWebhookOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
v["drop_pending_updates"] = strconv.FormatBool(opts.DropPendingUpdates)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "deleteWebhook", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// EditChatInviteLinkOpts is the set of optional fields for Bot.EditChatInviteLink and Bot.EditChatInviteLinkWithContext.
|
|
type EditChatInviteLinkOpts struct {
|
|
// Invite link name; 0-32 characters
|
|
Name string
|
|
// Point in time (Unix timestamp) when the link will expire
|
|
ExpireDate int64
|
|
// 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
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// EditChatInviteLink (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - inviteLink (type string): The invite link to edit
|
|
// - opts (type EditChatInviteLinkOpts): All optional parameters.
|
|
func (bot *Bot) EditChatInviteLink(chatId int64, inviteLink string, opts *EditChatInviteLinkOpts) (*ChatInviteLink, error) {
|
|
return bot.EditChatInviteLinkWithContext(context.Background(), chatId, inviteLink, opts)
|
|
}
|
|
|
|
// EditChatInviteLinkWithContext is the same as Bot.EditChatInviteLink, but with a context.Context parameter
|
|
func (bot *Bot) EditChatInviteLinkWithContext(ctx context.Context, chatId int64, inviteLink string, opts *EditChatInviteLinkOpts) (*ChatInviteLink, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["invite_link"] = inviteLink
|
|
if opts != nil {
|
|
v["name"] = opts.Name
|
|
if opts.ExpireDate != 0 {
|
|
v["expire_date"] = strconv.FormatInt(opts.ExpireDate, 10)
|
|
}
|
|
if opts.MemberLimit != 0 {
|
|
v["member_limit"] = strconv.FormatInt(opts.MemberLimit, 10)
|
|
}
|
|
v["creates_join_request"] = strconv.FormatBool(opts.CreatesJoinRequest)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "editChatInviteLink", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var c ChatInviteLink
|
|
return &c, json.Unmarshal(r, &c)
|
|
}
|
|
|
|
// EditChatSubscriptionInviteLinkOpts is the set of optional fields for Bot.EditChatSubscriptionInviteLink and Bot.EditChatSubscriptionInviteLinkWithContext.
|
|
type EditChatSubscriptionInviteLinkOpts struct {
|
|
// Invite link name; 0-32 characters
|
|
Name string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// EditChatSubscriptionInviteLink (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - inviteLink (type string): The invite link to edit
|
|
// - opts (type EditChatSubscriptionInviteLinkOpts): All optional parameters.
|
|
func (bot *Bot) EditChatSubscriptionInviteLink(chatId int64, inviteLink string, opts *EditChatSubscriptionInviteLinkOpts) (*ChatInviteLink, error) {
|
|
return bot.EditChatSubscriptionInviteLinkWithContext(context.Background(), chatId, inviteLink, opts)
|
|
}
|
|
|
|
// EditChatSubscriptionInviteLinkWithContext is the same as Bot.EditChatSubscriptionInviteLink, but with a context.Context parameter
|
|
func (bot *Bot) EditChatSubscriptionInviteLinkWithContext(ctx context.Context, chatId int64, inviteLink string, opts *EditChatSubscriptionInviteLinkOpts) (*ChatInviteLink, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["invite_link"] = inviteLink
|
|
if opts != nil {
|
|
v["name"] = opts.Name
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "editChatSubscriptionInviteLink", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var c ChatInviteLink
|
|
return &c, json.Unmarshal(r, &c)
|
|
}
|
|
|
|
// EditForumTopicOpts is the set of optional fields for Bot.EditForumTopic and Bot.EditForumTopicWithContext.
|
|
type EditForumTopicOpts struct {
|
|
// New topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept
|
|
Name string
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// EditForumTopic (https://core.telegram.org/bots/api#editforumtopic)
|
|
//
|
|
// Use this method to edit name and icon of a 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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - messageThreadId (type int64): Unique identifier for the target message thread of the forum topic
|
|
// - opts (type EditForumTopicOpts): All optional parameters.
|
|
func (bot *Bot) EditForumTopic(chatId int64, messageThreadId int64, opts *EditForumTopicOpts) (bool, error) {
|
|
return bot.EditForumTopicWithContext(context.Background(), chatId, messageThreadId, opts)
|
|
}
|
|
|
|
// EditForumTopicWithContext is the same as Bot.EditForumTopic, but with a context.Context parameter
|
|
func (bot *Bot) EditForumTopicWithContext(ctx context.Context, chatId int64, messageThreadId int64, opts *EditForumTopicOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["message_thread_id"] = strconv.FormatInt(messageThreadId, 10)
|
|
if opts != nil {
|
|
v["name"] = opts.Name
|
|
if opts.IconCustomEmojiId != nil {
|
|
v["icon_custom_emoji_id"] = *opts.IconCustomEmojiId
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "editForumTopic", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// EditGeneralForumTopicOpts is the set of optional fields for Bot.EditGeneralForumTopic and Bot.EditGeneralForumTopicWithContext.
|
|
type EditGeneralForumTopicOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// EditGeneralForumTopic (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - name (type string): New topic name, 1-128 characters
|
|
// - opts (type EditGeneralForumTopicOpts): All optional parameters.
|
|
func (bot *Bot) EditGeneralForumTopic(chatId int64, name string, opts *EditGeneralForumTopicOpts) (bool, error) {
|
|
return bot.EditGeneralForumTopicWithContext(context.Background(), chatId, name, opts)
|
|
}
|
|
|
|
// EditGeneralForumTopicWithContext is the same as Bot.EditGeneralForumTopic, but with a context.Context parameter
|
|
func (bot *Bot) EditGeneralForumTopicWithContext(ctx context.Context, chatId int64, name string, opts *EditGeneralForumTopicOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["name"] = name
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "editGeneralForumTopic", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// EditMessageCaptionOpts is the set of optional fields for Bot.EditMessageCaption and Bot.EditMessageCaptionWithContext.
|
|
type EditMessageCaptionOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionId string
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat
|
|
ChatId int64
|
|
// Required if inline_message_id is not specified. Identifier of the message to edit
|
|
MessageId int64
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message
|
|
InlineMessageId string
|
|
// New caption of the message, 0-1024 characters after entities parsing
|
|
Caption string
|
|
// Mode for parsing entities in the message caption. See formatting options for more details.
|
|
ParseMode string
|
|
// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
|
|
CaptionEntities []MessageEntity
|
|
// Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages.
|
|
ShowCaptionAboveMedia bool
|
|
// A JSON-serialized object for an inline keyboard.
|
|
ReplyMarkup InlineKeyboardMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// EditMessageCaption (https://core.telegram.org/bots/api#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.
|
|
// - opts (type EditMessageCaptionOpts): All optional parameters.
|
|
func (bot *Bot) EditMessageCaption(opts *EditMessageCaptionOpts) (*Message, bool, error) {
|
|
return bot.EditMessageCaptionWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// EditMessageCaptionWithContext is the same as Bot.EditMessageCaption, but with a context.Context parameter
|
|
func (bot *Bot) EditMessageCaptionWithContext(ctx context.Context, opts *EditMessageCaptionOpts) (*Message, bool, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.ChatId != 0 {
|
|
v["chat_id"] = strconv.FormatInt(opts.ChatId, 10)
|
|
}
|
|
if opts.MessageId != 0 {
|
|
v["message_id"] = strconv.FormatInt(opts.MessageId, 10)
|
|
}
|
|
v["inline_message_id"] = opts.InlineMessageId
|
|
v["caption"] = opts.Caption
|
|
v["parse_mode"] = opts.ParseMode
|
|
if opts.CaptionEntities != nil {
|
|
bs, err := json.Marshal(opts.CaptionEntities)
|
|
if err != nil {
|
|
return nil, false, fmt.Errorf("failed to marshal field caption_entities: %w", err)
|
|
}
|
|
v["caption_entities"] = string(bs)
|
|
}
|
|
v["show_caption_above_media"] = strconv.FormatBool(opts.ShowCaptionAboveMedia)
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, false, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "editMessageCaption", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, false, err
|
|
}
|
|
|
|
var m Message
|
|
if err := json.Unmarshal(r, &m); err != nil {
|
|
var b bool
|
|
if err := json.Unmarshal(r, &b); err != nil {
|
|
return nil, false, err
|
|
}
|
|
return nil, b, nil
|
|
}
|
|
return &m, true, nil
|
|
|
|
}
|
|
|
|
// EditMessageLiveLocationOpts is the set of optional fields for Bot.EditMessageLiveLocation and Bot.EditMessageLiveLocationWithContext.
|
|
type EditMessageLiveLocationOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionId string
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat
|
|
ChatId int64
|
|
// Required if inline_message_id is not specified. Identifier of the message to edit
|
|
MessageId int64
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message
|
|
InlineMessageId string
|
|
// 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
|
|
// The radius of uncertainty for the location, measured in meters; 0-1500
|
|
HorizontalAccuracy float64
|
|
// Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
|
|
Heading int64
|
|
// The maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
|
|
ProximityAlertRadius int64
|
|
// A JSON-serialized object for a new inline keyboard.
|
|
ReplyMarkup InlineKeyboardMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// EditMessageLiveLocation (https://core.telegram.org/bots/api#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.
|
|
// - latitude (type float64): Latitude of new location
|
|
// - longitude (type float64): Longitude of new location
|
|
// - opts (type EditMessageLiveLocationOpts): All optional parameters.
|
|
func (bot *Bot) EditMessageLiveLocation(latitude float64, longitude float64, opts *EditMessageLiveLocationOpts) (*Message, bool, error) {
|
|
return bot.EditMessageLiveLocationWithContext(context.Background(), latitude, longitude, opts)
|
|
}
|
|
|
|
// EditMessageLiveLocationWithContext is the same as Bot.EditMessageLiveLocation, but with a context.Context parameter
|
|
func (bot *Bot) EditMessageLiveLocationWithContext(ctx context.Context, latitude float64, longitude float64, opts *EditMessageLiveLocationOpts) (*Message, bool, error) {
|
|
v := map[string]string{}
|
|
v["latitude"] = strconv.FormatFloat(latitude, 'f', -1, 64)
|
|
v["longitude"] = strconv.FormatFloat(longitude, 'f', -1, 64)
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.ChatId != 0 {
|
|
v["chat_id"] = strconv.FormatInt(opts.ChatId, 10)
|
|
}
|
|
if opts.MessageId != 0 {
|
|
v["message_id"] = strconv.FormatInt(opts.MessageId, 10)
|
|
}
|
|
v["inline_message_id"] = opts.InlineMessageId
|
|
if opts.LivePeriod != nil {
|
|
v["live_period"] = strconv.FormatInt(*opts.LivePeriod, 10)
|
|
}
|
|
if opts.HorizontalAccuracy != 0.0 {
|
|
v["horizontal_accuracy"] = strconv.FormatFloat(opts.HorizontalAccuracy, 'f', -1, 64)
|
|
}
|
|
if opts.Heading != 0 {
|
|
v["heading"] = strconv.FormatInt(opts.Heading, 10)
|
|
}
|
|
if opts.ProximityAlertRadius != 0 {
|
|
v["proximity_alert_radius"] = strconv.FormatInt(opts.ProximityAlertRadius, 10)
|
|
}
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, false, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "editMessageLiveLocation", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, false, err
|
|
}
|
|
|
|
var m Message
|
|
if err := json.Unmarshal(r, &m); err != nil {
|
|
var b bool
|
|
if err := json.Unmarshal(r, &b); err != nil {
|
|
return nil, false, err
|
|
}
|
|
return nil, b, nil
|
|
}
|
|
return &m, true, nil
|
|
|
|
}
|
|
|
|
// EditMessageMediaOpts is the set of optional fields for Bot.EditMessageMedia and Bot.EditMessageMediaWithContext.
|
|
type EditMessageMediaOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionId string
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat
|
|
ChatId int64
|
|
// Required if inline_message_id is not specified. Identifier of the message to edit
|
|
MessageId int64
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message
|
|
InlineMessageId string
|
|
// A JSON-serialized object for a new inline keyboard.
|
|
ReplyMarkup InlineKeyboardMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// EditMessageMedia (https://core.telegram.org/bots/api#editmessagemedia)
|
|
//
|
|
// Use this method to edit animation, audio, document, 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 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.
|
|
// - media (type InputMedia): A JSON-serialized object for a new media content of the message
|
|
// - opts (type EditMessageMediaOpts): All optional parameters.
|
|
func (bot *Bot) EditMessageMedia(media InputMedia, opts *EditMessageMediaOpts) (*Message, bool, error) {
|
|
return bot.EditMessageMediaWithContext(context.Background(), media, opts)
|
|
}
|
|
|
|
// EditMessageMediaWithContext is the same as Bot.EditMessageMedia, but with a context.Context parameter
|
|
func (bot *Bot) EditMessageMediaWithContext(ctx context.Context, media InputMedia, opts *EditMessageMediaOpts) (*Message, bool, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
inputBs, err := media.InputParams("media", data)
|
|
if err != nil {
|
|
return nil, false, fmt.Errorf("failed to marshal field media: %w", err)
|
|
}
|
|
v["media"] = string(inputBs)
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.ChatId != 0 {
|
|
v["chat_id"] = strconv.FormatInt(opts.ChatId, 10)
|
|
}
|
|
if opts.MessageId != 0 {
|
|
v["message_id"] = strconv.FormatInt(opts.MessageId, 10)
|
|
}
|
|
v["inline_message_id"] = opts.InlineMessageId
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, false, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "editMessageMedia", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, false, err
|
|
}
|
|
|
|
var m Message
|
|
if err := json.Unmarshal(r, &m); err != nil {
|
|
var b bool
|
|
if err := json.Unmarshal(r, &b); err != nil {
|
|
return nil, false, err
|
|
}
|
|
return nil, b, nil
|
|
}
|
|
return &m, true, nil
|
|
|
|
}
|
|
|
|
// EditMessageReplyMarkupOpts is the set of optional fields for Bot.EditMessageReplyMarkup and Bot.EditMessageReplyMarkupWithContext.
|
|
type EditMessageReplyMarkupOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionId string
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat
|
|
ChatId int64
|
|
// Required if inline_message_id is not specified. Identifier of the message to edit
|
|
MessageId int64
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message
|
|
InlineMessageId string
|
|
// A JSON-serialized object for an inline keyboard.
|
|
ReplyMarkup InlineKeyboardMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// EditMessageReplyMarkup (https://core.telegram.org/bots/api#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.
|
|
// - opts (type EditMessageReplyMarkupOpts): All optional parameters.
|
|
func (bot *Bot) EditMessageReplyMarkup(opts *EditMessageReplyMarkupOpts) (*Message, bool, error) {
|
|
return bot.EditMessageReplyMarkupWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// EditMessageReplyMarkupWithContext is the same as Bot.EditMessageReplyMarkup, but with a context.Context parameter
|
|
func (bot *Bot) EditMessageReplyMarkupWithContext(ctx context.Context, opts *EditMessageReplyMarkupOpts) (*Message, bool, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.ChatId != 0 {
|
|
v["chat_id"] = strconv.FormatInt(opts.ChatId, 10)
|
|
}
|
|
if opts.MessageId != 0 {
|
|
v["message_id"] = strconv.FormatInt(opts.MessageId, 10)
|
|
}
|
|
v["inline_message_id"] = opts.InlineMessageId
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, false, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "editMessageReplyMarkup", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, false, err
|
|
}
|
|
|
|
var m Message
|
|
if err := json.Unmarshal(r, &m); err != nil {
|
|
var b bool
|
|
if err := json.Unmarshal(r, &b); err != nil {
|
|
return nil, false, err
|
|
}
|
|
return nil, b, nil
|
|
}
|
|
return &m, true, nil
|
|
|
|
}
|
|
|
|
// EditMessageTextOpts is the set of optional fields for Bot.EditMessageText and Bot.EditMessageTextWithContext.
|
|
type EditMessageTextOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionId string
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat
|
|
ChatId int64
|
|
// Required if inline_message_id is not specified. Identifier of the message to edit
|
|
MessageId int64
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message
|
|
InlineMessageId string
|
|
// Mode for parsing entities in the message text. See formatting options for more details.
|
|
ParseMode string
|
|
// A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode
|
|
Entities []MessageEntity
|
|
// Link preview generation options for the message
|
|
LinkPreviewOptions *LinkPreviewOptions
|
|
// A JSON-serialized object for an inline keyboard.
|
|
ReplyMarkup InlineKeyboardMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// EditMessageText (https://core.telegram.org/bots/api#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.
|
|
// - text (type string): New text of the message, 1-4096 characters after entities parsing
|
|
// - opts (type EditMessageTextOpts): All optional parameters.
|
|
func (bot *Bot) EditMessageText(text string, opts *EditMessageTextOpts) (*Message, bool, error) {
|
|
return bot.EditMessageTextWithContext(context.Background(), text, opts)
|
|
}
|
|
|
|
// EditMessageTextWithContext is the same as Bot.EditMessageText, but with a context.Context parameter
|
|
func (bot *Bot) EditMessageTextWithContext(ctx context.Context, text string, opts *EditMessageTextOpts) (*Message, bool, error) {
|
|
v := map[string]string{}
|
|
v["text"] = text
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.ChatId != 0 {
|
|
v["chat_id"] = strconv.FormatInt(opts.ChatId, 10)
|
|
}
|
|
if opts.MessageId != 0 {
|
|
v["message_id"] = strconv.FormatInt(opts.MessageId, 10)
|
|
}
|
|
v["inline_message_id"] = opts.InlineMessageId
|
|
v["parse_mode"] = opts.ParseMode
|
|
if opts.Entities != nil {
|
|
bs, err := json.Marshal(opts.Entities)
|
|
if err != nil {
|
|
return nil, false, fmt.Errorf("failed to marshal field entities: %w", err)
|
|
}
|
|
v["entities"] = string(bs)
|
|
}
|
|
if opts.LinkPreviewOptions != nil {
|
|
bs, err := json.Marshal(opts.LinkPreviewOptions)
|
|
if err != nil {
|
|
return nil, false, fmt.Errorf("failed to marshal field link_preview_options: %w", err)
|
|
}
|
|
v["link_preview_options"] = string(bs)
|
|
}
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, false, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "editMessageText", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, false, err
|
|
}
|
|
|
|
var m Message
|
|
if err := json.Unmarshal(r, &m); err != nil {
|
|
var b bool
|
|
if err := json.Unmarshal(r, &b); err != nil {
|
|
return nil, false, err
|
|
}
|
|
return nil, b, nil
|
|
}
|
|
return &m, true, nil
|
|
|
|
}
|
|
|
|
// ExportChatInviteLinkOpts is the set of optional fields for Bot.ExportChatInviteLink and Bot.ExportChatInviteLinkWithContext.
|
|
type ExportChatInviteLinkOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// ExportChatInviteLink (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type ExportChatInviteLinkOpts): All optional parameters.
|
|
func (bot *Bot) ExportChatInviteLink(chatId int64, opts *ExportChatInviteLinkOpts) (string, error) {
|
|
return bot.ExportChatInviteLinkWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// ExportChatInviteLinkWithContext is the same as Bot.ExportChatInviteLink, but with a context.Context parameter
|
|
func (bot *Bot) ExportChatInviteLinkWithContext(ctx context.Context, chatId int64, opts *ExportChatInviteLinkOpts) (string, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "exportChatInviteLink", v, nil, reqOpts)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
var s string
|
|
return s, json.Unmarshal(r, &s)
|
|
}
|
|
|
|
// ForwardMessageOpts is the set of optional fields for Bot.ForwardMessage and Bot.ForwardMessageWithContext.
|
|
type ForwardMessageOpts struct {
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the forwarded message from forwarding and saving
|
|
ProtectContent bool
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// ForwardMessage (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - fromChatId (type int64): Unique identifier for the chat where the original message was sent
|
|
// - messageId (type int64): Message identifier in the chat specified in from_chat_id
|
|
// - opts (type ForwardMessageOpts): All optional parameters.
|
|
func (bot *Bot) ForwardMessage(chatId int64, fromChatId int64, messageId int64, opts *ForwardMessageOpts) (*Message, error) {
|
|
return bot.ForwardMessageWithContext(context.Background(), chatId, fromChatId, messageId, opts)
|
|
}
|
|
|
|
// ForwardMessageWithContext is the same as Bot.ForwardMessage, but with a context.Context parameter
|
|
func (bot *Bot) ForwardMessageWithContext(ctx context.Context, chatId int64, fromChatId int64, messageId int64, opts *ForwardMessageOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["from_chat_id"] = strconv.FormatInt(fromChatId, 10)
|
|
v["message_id"] = strconv.FormatInt(messageId, 10)
|
|
if opts != nil {
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "forwardMessage", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// ForwardMessagesOpts is the set of optional fields for Bot.ForwardMessages and Bot.ForwardMessagesWithContext.
|
|
type ForwardMessagesOpts struct {
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Sends the messages silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the forwarded messages from forwarding and saving
|
|
ProtectContent bool
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// ForwardMessages (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - fromChatId (type int64): Unique identifier for the chat where the original messages were sent
|
|
// - messageIds (type []int64): 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.
|
|
// - opts (type ForwardMessagesOpts): All optional parameters.
|
|
func (bot *Bot) ForwardMessages(chatId int64, fromChatId int64, messageIds []int64, opts *ForwardMessagesOpts) ([]MessageId, error) {
|
|
return bot.ForwardMessagesWithContext(context.Background(), chatId, fromChatId, messageIds, opts)
|
|
}
|
|
|
|
// ForwardMessagesWithContext is the same as Bot.ForwardMessages, but with a context.Context parameter
|
|
func (bot *Bot) ForwardMessagesWithContext(ctx context.Context, chatId int64, fromChatId int64, messageIds []int64, opts *ForwardMessagesOpts) ([]MessageId, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["from_chat_id"] = strconv.FormatInt(fromChatId, 10)
|
|
if messageIds != nil {
|
|
bs, err := json.Marshal(messageIds)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field message_ids: %w", err)
|
|
}
|
|
v["message_ids"] = string(bs)
|
|
}
|
|
if opts != nil {
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "forwardMessages", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m []MessageId
|
|
return m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// GetBusinessConnectionOpts is the set of optional fields for Bot.GetBusinessConnection and Bot.GetBusinessConnectionWithContext.
|
|
type GetBusinessConnectionOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetBusinessConnection (https://core.telegram.org/bots/api#getbusinessconnection)
|
|
//
|
|
// Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
|
|
// - businessConnectionId (type string): Unique identifier of the business connection
|
|
// - opts (type GetBusinessConnectionOpts): All optional parameters.
|
|
func (bot *Bot) GetBusinessConnection(businessConnectionId string, opts *GetBusinessConnectionOpts) (*BusinessConnection, error) {
|
|
return bot.GetBusinessConnectionWithContext(context.Background(), businessConnectionId, opts)
|
|
}
|
|
|
|
// GetBusinessConnectionWithContext is the same as Bot.GetBusinessConnection, but with a context.Context parameter
|
|
func (bot *Bot) GetBusinessConnectionWithContext(ctx context.Context, businessConnectionId string, opts *GetBusinessConnectionOpts) (*BusinessConnection, error) {
|
|
v := map[string]string{}
|
|
v["business_connection_id"] = businessConnectionId
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getBusinessConnection", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var b BusinessConnection
|
|
return &b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// GetChatOpts is the set of optional fields for Bot.GetChat and Bot.GetChatWithContext.
|
|
type GetChatOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetChat (https://core.telegram.org/bots/api#getchat)
|
|
//
|
|
// Use this method to get up-to-date information about the chat. Returns a ChatFullInfo object on success.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type GetChatOpts): All optional parameters.
|
|
func (bot *Bot) GetChat(chatId int64, opts *GetChatOpts) (*ChatFullInfo, error) {
|
|
return bot.GetChatWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// GetChatWithContext is the same as Bot.GetChat, but with a context.Context parameter
|
|
func (bot *Bot) GetChatWithContext(ctx context.Context, chatId int64, opts *GetChatOpts) (*ChatFullInfo, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getChat", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var c ChatFullInfo
|
|
return &c, json.Unmarshal(r, &c)
|
|
}
|
|
|
|
// GetChatAdministratorsOpts is the set of optional fields for Bot.GetChatAdministrators and Bot.GetChatAdministratorsWithContext.
|
|
type GetChatAdministratorsOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetChatAdministrators (https://core.telegram.org/bots/api#getchatadministrators)
|
|
//
|
|
// Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type GetChatAdministratorsOpts): All optional parameters.
|
|
func (bot *Bot) GetChatAdministrators(chatId int64, opts *GetChatAdministratorsOpts) ([]ChatMember, error) {
|
|
return bot.GetChatAdministratorsWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// GetChatAdministratorsWithContext is the same as Bot.GetChatAdministrators, but with a context.Context parameter
|
|
func (bot *Bot) GetChatAdministratorsWithContext(ctx context.Context, chatId int64, opts *GetChatAdministratorsOpts) ([]ChatMember, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getChatAdministrators", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return unmarshalChatMemberArray(r)
|
|
}
|
|
|
|
// GetChatMemberOpts is the set of optional fields for Bot.GetChatMember and Bot.GetChatMemberWithContext.
|
|
type GetChatMemberOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetChatMember (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - userId (type int64): Unique identifier of the target user
|
|
// - opts (type GetChatMemberOpts): All optional parameters.
|
|
func (bot *Bot) GetChatMember(chatId int64, userId int64, opts *GetChatMemberOpts) (ChatMember, error) {
|
|
return bot.GetChatMemberWithContext(context.Background(), chatId, userId, opts)
|
|
}
|
|
|
|
// GetChatMemberWithContext is the same as Bot.GetChatMember, but with a context.Context parameter
|
|
func (bot *Bot) GetChatMemberWithContext(ctx context.Context, chatId int64, userId int64, opts *GetChatMemberOpts) (ChatMember, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getChatMember", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return unmarshalChatMember(r)
|
|
}
|
|
|
|
// GetChatMemberCountOpts is the set of optional fields for Bot.GetChatMemberCount and Bot.GetChatMemberCountWithContext.
|
|
type GetChatMemberCountOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetChatMemberCount (https://core.telegram.org/bots/api#getchatmembercount)
|
|
//
|
|
// Use this method to get the number of members in a chat. Returns Int on success.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type GetChatMemberCountOpts): All optional parameters.
|
|
func (bot *Bot) GetChatMemberCount(chatId int64, opts *GetChatMemberCountOpts) (int64, error) {
|
|
return bot.GetChatMemberCountWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// GetChatMemberCountWithContext is the same as Bot.GetChatMemberCount, but with a context.Context parameter
|
|
func (bot *Bot) GetChatMemberCountWithContext(ctx context.Context, chatId int64, opts *GetChatMemberCountOpts) (int64, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getChatMemberCount", v, nil, reqOpts)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
var i int64
|
|
return i, json.Unmarshal(r, &i)
|
|
}
|
|
|
|
// GetChatMenuButtonOpts is the set of optional fields for Bot.GetChatMenuButton and Bot.GetChatMenuButtonWithContext.
|
|
type GetChatMenuButtonOpts struct {
|
|
// Unique identifier for the target private chat. If not specified, default bot's menu button will be returned
|
|
ChatId *int64
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetChatMenuButton (https://core.telegram.org/bots/api#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.
|
|
// - opts (type GetChatMenuButtonOpts): All optional parameters.
|
|
func (bot *Bot) GetChatMenuButton(opts *GetChatMenuButtonOpts) (MenuButton, error) {
|
|
return bot.GetChatMenuButtonWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// GetChatMenuButtonWithContext is the same as Bot.GetChatMenuButton, but with a context.Context parameter
|
|
func (bot *Bot) GetChatMenuButtonWithContext(ctx context.Context, opts *GetChatMenuButtonOpts) (MenuButton, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
if opts.ChatId != nil {
|
|
v["chat_id"] = strconv.FormatInt(*opts.ChatId, 10)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getChatMenuButton", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return unmarshalMenuButton(r)
|
|
}
|
|
|
|
// GetCustomEmojiStickersOpts is the set of optional fields for Bot.GetCustomEmojiStickers and Bot.GetCustomEmojiStickersWithContext.
|
|
type GetCustomEmojiStickersOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetCustomEmojiStickers (https://core.telegram.org/bots/api#getcustomemojistickers)
|
|
//
|
|
// Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects.
|
|
// - customEmojiIds (type []string): A JSON-serialized list of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
|
|
// - opts (type GetCustomEmojiStickersOpts): All optional parameters.
|
|
func (bot *Bot) GetCustomEmojiStickers(customEmojiIds []string, opts *GetCustomEmojiStickersOpts) ([]Sticker, error) {
|
|
return bot.GetCustomEmojiStickersWithContext(context.Background(), customEmojiIds, opts)
|
|
}
|
|
|
|
// GetCustomEmojiStickersWithContext is the same as Bot.GetCustomEmojiStickers, but with a context.Context parameter
|
|
func (bot *Bot) GetCustomEmojiStickersWithContext(ctx context.Context, customEmojiIds []string, opts *GetCustomEmojiStickersOpts) ([]Sticker, error) {
|
|
v := map[string]string{}
|
|
if customEmojiIds != nil {
|
|
bs, err := json.Marshal(customEmojiIds)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field custom_emoji_ids: %w", err)
|
|
}
|
|
v["custom_emoji_ids"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getCustomEmojiStickers", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var s []Sticker
|
|
return s, json.Unmarshal(r, &s)
|
|
}
|
|
|
|
// GetFileOpts is the set of optional fields for Bot.GetFile and Bot.GetFileWithContext.
|
|
type GetFileOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetFile (https://core.telegram.org/bots/api#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.
|
|
// - fileId (type string): File identifier to get information about
|
|
// - opts (type GetFileOpts): All optional parameters.
|
|
func (bot *Bot) GetFile(fileId string, opts *GetFileOpts) (*File, error) {
|
|
return bot.GetFileWithContext(context.Background(), fileId, opts)
|
|
}
|
|
|
|
// GetFileWithContext is the same as Bot.GetFile, but with a context.Context parameter
|
|
func (bot *Bot) GetFileWithContext(ctx context.Context, fileId string, opts *GetFileOpts) (*File, error) {
|
|
v := map[string]string{}
|
|
v["file_id"] = fileId
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getFile", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var f File
|
|
return &f, json.Unmarshal(r, &f)
|
|
}
|
|
|
|
// GetForumTopicIconStickersOpts is the set of optional fields for Bot.GetForumTopicIconStickers and Bot.GetForumTopicIconStickersWithContext.
|
|
type GetForumTopicIconStickersOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetForumTopicIconStickers (https://core.telegram.org/bots/api#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.
|
|
// - opts (type GetForumTopicIconStickersOpts): All optional parameters.
|
|
func (bot *Bot) GetForumTopicIconStickers(opts *GetForumTopicIconStickersOpts) ([]Sticker, error) {
|
|
return bot.GetForumTopicIconStickersWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// GetForumTopicIconStickersWithContext is the same as Bot.GetForumTopicIconStickers, but with a context.Context parameter
|
|
func (bot *Bot) GetForumTopicIconStickersWithContext(ctx context.Context, opts *GetForumTopicIconStickersOpts) ([]Sticker, error) {
|
|
v := map[string]string{}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getForumTopicIconStickers", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var s []Sticker
|
|
return s, json.Unmarshal(r, &s)
|
|
}
|
|
|
|
// GetGameHighScoresOpts is the set of optional fields for Bot.GetGameHighScores and Bot.GetGameHighScoresWithContext.
|
|
type GetGameHighScoresOpts struct {
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat
|
|
ChatId int64
|
|
// Required if inline_message_id is not specified. Identifier of the sent message
|
|
MessageId int64
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message
|
|
InlineMessageId string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetGameHighScores (https://core.telegram.org/bots/api#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.
|
|
// - userId (type int64): Target user id
|
|
// - opts (type GetGameHighScoresOpts): All optional parameters.
|
|
func (bot *Bot) GetGameHighScores(userId int64, opts *GetGameHighScoresOpts) ([]GameHighScore, error) {
|
|
return bot.GetGameHighScoresWithContext(context.Background(), userId, opts)
|
|
}
|
|
|
|
// GetGameHighScoresWithContext is the same as Bot.GetGameHighScores, but with a context.Context parameter
|
|
func (bot *Bot) GetGameHighScoresWithContext(ctx context.Context, userId int64, opts *GetGameHighScoresOpts) ([]GameHighScore, error) {
|
|
v := map[string]string{}
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
if opts != nil {
|
|
if opts.ChatId != 0 {
|
|
v["chat_id"] = strconv.FormatInt(opts.ChatId, 10)
|
|
}
|
|
if opts.MessageId != 0 {
|
|
v["message_id"] = strconv.FormatInt(opts.MessageId, 10)
|
|
}
|
|
v["inline_message_id"] = opts.InlineMessageId
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getGameHighScores", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var g []GameHighScore
|
|
return g, json.Unmarshal(r, &g)
|
|
}
|
|
|
|
// GetMeOpts is the set of optional fields for Bot.GetMe and Bot.GetMeWithContext.
|
|
type GetMeOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetMe (https://core.telegram.org/bots/api#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.
|
|
// - opts (type GetMeOpts): All optional parameters.
|
|
func (bot *Bot) GetMe(opts *GetMeOpts) (*User, error) {
|
|
return bot.GetMeWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// GetMeWithContext is the same as Bot.GetMe, but with a context.Context parameter
|
|
func (bot *Bot) GetMeWithContext(ctx context.Context, opts *GetMeOpts) (*User, error) {
|
|
v := map[string]string{}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getMe", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var u User
|
|
return &u, json.Unmarshal(r, &u)
|
|
}
|
|
|
|
// GetMyCommandsOpts is the set of optional fields for Bot.GetMyCommands and Bot.GetMyCommandsWithContext.
|
|
type GetMyCommandsOpts struct {
|
|
// A JSON-serialized object, describing scope of users. Defaults to BotCommandScopeDefault.
|
|
Scope BotCommandScope
|
|
// A two-letter ISO 639-1 language code or an empty string
|
|
LanguageCode string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetMyCommands (https://core.telegram.org/bots/api#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.
|
|
// - opts (type GetMyCommandsOpts): All optional parameters.
|
|
func (bot *Bot) GetMyCommands(opts *GetMyCommandsOpts) ([]BotCommand, error) {
|
|
return bot.GetMyCommandsWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// GetMyCommandsWithContext is the same as Bot.GetMyCommands, but with a context.Context parameter
|
|
func (bot *Bot) GetMyCommandsWithContext(ctx context.Context, opts *GetMyCommandsOpts) ([]BotCommand, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
bs, err := json.Marshal(opts.Scope)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field scope: %w", err)
|
|
}
|
|
v["scope"] = string(bs)
|
|
v["language_code"] = opts.LanguageCode
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getMyCommands", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var b []BotCommand
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// GetMyDefaultAdministratorRightsOpts is the set of optional fields for Bot.GetMyDefaultAdministratorRights and Bot.GetMyDefaultAdministratorRightsWithContext.
|
|
type GetMyDefaultAdministratorRightsOpts 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetMyDefaultAdministratorRights (https://core.telegram.org/bots/api#getmydefaultadministratorrights)
|
|
//
|
|
// Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
|
|
// - opts (type GetMyDefaultAdministratorRightsOpts): All optional parameters.
|
|
func (bot *Bot) GetMyDefaultAdministratorRights(opts *GetMyDefaultAdministratorRightsOpts) (*ChatAdministratorRights, error) {
|
|
return bot.GetMyDefaultAdministratorRightsWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// GetMyDefaultAdministratorRightsWithContext is the same as Bot.GetMyDefaultAdministratorRights, but with a context.Context parameter
|
|
func (bot *Bot) GetMyDefaultAdministratorRightsWithContext(ctx context.Context, opts *GetMyDefaultAdministratorRightsOpts) (*ChatAdministratorRights, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
v["for_channels"] = strconv.FormatBool(opts.ForChannels)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getMyDefaultAdministratorRights", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var c ChatAdministratorRights
|
|
return &c, json.Unmarshal(r, &c)
|
|
}
|
|
|
|
// GetMyDescriptionOpts is the set of optional fields for Bot.GetMyDescription and Bot.GetMyDescriptionWithContext.
|
|
type GetMyDescriptionOpts struct {
|
|
// A two-letter ISO 639-1 language code or an empty string
|
|
LanguageCode string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetMyDescription (https://core.telegram.org/bots/api#getmydescription)
|
|
//
|
|
// Use this method to get the current bot description for the given user language. Returns BotDescription on success.
|
|
// - opts (type GetMyDescriptionOpts): All optional parameters.
|
|
func (bot *Bot) GetMyDescription(opts *GetMyDescriptionOpts) (*BotDescription, error) {
|
|
return bot.GetMyDescriptionWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// GetMyDescriptionWithContext is the same as Bot.GetMyDescription, but with a context.Context parameter
|
|
func (bot *Bot) GetMyDescriptionWithContext(ctx context.Context, opts *GetMyDescriptionOpts) (*BotDescription, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
v["language_code"] = opts.LanguageCode
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getMyDescription", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var b BotDescription
|
|
return &b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// GetMyNameOpts is the set of optional fields for Bot.GetMyName and Bot.GetMyNameWithContext.
|
|
type GetMyNameOpts struct {
|
|
// A two-letter ISO 639-1 language code or an empty string
|
|
LanguageCode string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetMyName (https://core.telegram.org/bots/api#getmyname)
|
|
//
|
|
// Use this method to get the current bot name for the given user language. Returns BotName on success.
|
|
// - opts (type GetMyNameOpts): All optional parameters.
|
|
func (bot *Bot) GetMyName(opts *GetMyNameOpts) (*BotName, error) {
|
|
return bot.GetMyNameWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// GetMyNameWithContext is the same as Bot.GetMyName, but with a context.Context parameter
|
|
func (bot *Bot) GetMyNameWithContext(ctx context.Context, opts *GetMyNameOpts) (*BotName, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
v["language_code"] = opts.LanguageCode
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getMyName", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var b BotName
|
|
return &b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// GetMyShortDescriptionOpts is the set of optional fields for Bot.GetMyShortDescription and Bot.GetMyShortDescriptionWithContext.
|
|
type GetMyShortDescriptionOpts struct {
|
|
// A two-letter ISO 639-1 language code or an empty string
|
|
LanguageCode string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetMyShortDescription (https://core.telegram.org/bots/api#getmyshortdescription)
|
|
//
|
|
// Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success.
|
|
// - opts (type GetMyShortDescriptionOpts): All optional parameters.
|
|
func (bot *Bot) GetMyShortDescription(opts *GetMyShortDescriptionOpts) (*BotShortDescription, error) {
|
|
return bot.GetMyShortDescriptionWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// GetMyShortDescriptionWithContext is the same as Bot.GetMyShortDescription, but with a context.Context parameter
|
|
func (bot *Bot) GetMyShortDescriptionWithContext(ctx context.Context, opts *GetMyShortDescriptionOpts) (*BotShortDescription, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
v["language_code"] = opts.LanguageCode
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getMyShortDescription", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var b BotShortDescription
|
|
return &b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// GetStarTransactionsOpts is the set of optional fields for Bot.GetStarTransactions and Bot.GetStarTransactionsWithContext.
|
|
type GetStarTransactionsOpts struct {
|
|
// Number of transactions to skip in the response
|
|
Offset int64
|
|
// The maximum number of transactions to be retrieved. Values between 1-100 are accepted. Defaults to 100.
|
|
Limit int64
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetStarTransactions (https://core.telegram.org/bots/api#getstartransactions)
|
|
//
|
|
// Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object.
|
|
// - opts (type GetStarTransactionsOpts): All optional parameters.
|
|
func (bot *Bot) GetStarTransactions(opts *GetStarTransactionsOpts) (*StarTransactions, error) {
|
|
return bot.GetStarTransactionsWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// GetStarTransactionsWithContext is the same as Bot.GetStarTransactions, but with a context.Context parameter
|
|
func (bot *Bot) GetStarTransactionsWithContext(ctx context.Context, opts *GetStarTransactionsOpts) (*StarTransactions, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
if opts.Offset != 0 {
|
|
v["offset"] = strconv.FormatInt(opts.Offset, 10)
|
|
}
|
|
if opts.Limit != 0 {
|
|
v["limit"] = strconv.FormatInt(opts.Limit, 10)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getStarTransactions", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var s StarTransactions
|
|
return &s, json.Unmarshal(r, &s)
|
|
}
|
|
|
|
// GetStickerSetOpts is the set of optional fields for Bot.GetStickerSet and Bot.GetStickerSetWithContext.
|
|
type GetStickerSetOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetStickerSet (https://core.telegram.org/bots/api#getstickerset)
|
|
//
|
|
// Use this method to get a sticker set. On success, a StickerSet object is returned.
|
|
// - name (type string): Name of the sticker set
|
|
// - opts (type GetStickerSetOpts): All optional parameters.
|
|
func (bot *Bot) GetStickerSet(name string, opts *GetStickerSetOpts) (*StickerSet, error) {
|
|
return bot.GetStickerSetWithContext(context.Background(), name, opts)
|
|
}
|
|
|
|
// GetStickerSetWithContext is the same as Bot.GetStickerSet, but with a context.Context parameter
|
|
func (bot *Bot) GetStickerSetWithContext(ctx context.Context, name string, opts *GetStickerSetOpts) (*StickerSet, error) {
|
|
v := map[string]string{}
|
|
v["name"] = name
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getStickerSet", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var s StickerSet
|
|
return &s, json.Unmarshal(r, &s)
|
|
}
|
|
|
|
// GetUpdatesOpts is the set of optional fields for Bot.GetUpdates and Bot.GetUpdatesWithContext.
|
|
type GetUpdatesOpts 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
|
|
// Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.
|
|
Limit int64
|
|
// 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
|
|
// 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 getUpdates, so unwanted updates may be received for a short period of time.
|
|
AllowedUpdates []string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetUpdates (https://core.telegram.org/bots/api#getupdates)
|
|
//
|
|
// Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects.
|
|
// - opts (type GetUpdatesOpts): All optional parameters.
|
|
func (bot *Bot) GetUpdates(opts *GetUpdatesOpts) ([]Update, error) {
|
|
return bot.GetUpdatesWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// GetUpdatesWithContext is the same as Bot.GetUpdates, but with a context.Context parameter
|
|
func (bot *Bot) GetUpdatesWithContext(ctx context.Context, opts *GetUpdatesOpts) ([]Update, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
if opts.Offset != 0 {
|
|
v["offset"] = strconv.FormatInt(opts.Offset, 10)
|
|
}
|
|
if opts.Limit != 0 {
|
|
v["limit"] = strconv.FormatInt(opts.Limit, 10)
|
|
}
|
|
if opts.Timeout != 0 {
|
|
v["timeout"] = strconv.FormatInt(opts.Timeout, 10)
|
|
}
|
|
if opts.AllowedUpdates != nil {
|
|
bs, err := json.Marshal(opts.AllowedUpdates)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field allowed_updates: %w", err)
|
|
}
|
|
v["allowed_updates"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getUpdates", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var u []Update
|
|
return u, json.Unmarshal(r, &u)
|
|
}
|
|
|
|
// GetUserChatBoostsOpts is the set of optional fields for Bot.GetUserChatBoosts and Bot.GetUserChatBoostsWithContext.
|
|
type GetUserChatBoostsOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetUserChatBoosts (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the chat
|
|
// - userId (type int64): Unique identifier of the target user
|
|
// - opts (type GetUserChatBoostsOpts): All optional parameters.
|
|
func (bot *Bot) GetUserChatBoosts(chatId int64, userId int64, opts *GetUserChatBoostsOpts) (*UserChatBoosts, error) {
|
|
return bot.GetUserChatBoostsWithContext(context.Background(), chatId, userId, opts)
|
|
}
|
|
|
|
// GetUserChatBoostsWithContext is the same as Bot.GetUserChatBoosts, but with a context.Context parameter
|
|
func (bot *Bot) GetUserChatBoostsWithContext(ctx context.Context, chatId int64, userId int64, opts *GetUserChatBoostsOpts) (*UserChatBoosts, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getUserChatBoosts", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var u UserChatBoosts
|
|
return &u, json.Unmarshal(r, &u)
|
|
}
|
|
|
|
// GetUserProfilePhotosOpts is the set of optional fields for Bot.GetUserProfilePhotos and Bot.GetUserProfilePhotosWithContext.
|
|
type GetUserProfilePhotosOpts struct {
|
|
// Sequential number of the first photo to be returned. By default, all photos are returned.
|
|
Offset int64
|
|
// Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to 100.
|
|
Limit int64
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetUserProfilePhotos (https://core.telegram.org/bots/api#getuserprofilephotos)
|
|
//
|
|
// Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
|
|
// - userId (type int64): Unique identifier of the target user
|
|
// - opts (type GetUserProfilePhotosOpts): All optional parameters.
|
|
func (bot *Bot) GetUserProfilePhotos(userId int64, opts *GetUserProfilePhotosOpts) (*UserProfilePhotos, error) {
|
|
return bot.GetUserProfilePhotosWithContext(context.Background(), userId, opts)
|
|
}
|
|
|
|
// GetUserProfilePhotosWithContext is the same as Bot.GetUserProfilePhotos, but with a context.Context parameter
|
|
func (bot *Bot) GetUserProfilePhotosWithContext(ctx context.Context, userId int64, opts *GetUserProfilePhotosOpts) (*UserProfilePhotos, error) {
|
|
v := map[string]string{}
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
if opts != nil {
|
|
if opts.Offset != 0 {
|
|
v["offset"] = strconv.FormatInt(opts.Offset, 10)
|
|
}
|
|
if opts.Limit != 0 {
|
|
v["limit"] = strconv.FormatInt(opts.Limit, 10)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getUserProfilePhotos", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var u UserProfilePhotos
|
|
return &u, json.Unmarshal(r, &u)
|
|
}
|
|
|
|
// GetWebhookInfoOpts is the set of optional fields for Bot.GetWebhookInfo and Bot.GetWebhookInfoWithContext.
|
|
type GetWebhookInfoOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// GetWebhookInfo (https://core.telegram.org/bots/api#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.
|
|
// - opts (type GetWebhookInfoOpts): All optional parameters.
|
|
func (bot *Bot) GetWebhookInfo(opts *GetWebhookInfoOpts) (*WebhookInfo, error) {
|
|
return bot.GetWebhookInfoWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// GetWebhookInfoWithContext is the same as Bot.GetWebhookInfo, but with a context.Context parameter
|
|
func (bot *Bot) GetWebhookInfoWithContext(ctx context.Context, opts *GetWebhookInfoOpts) (*WebhookInfo, error) {
|
|
v := map[string]string{}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "getWebhookInfo", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var w WebhookInfo
|
|
return &w, json.Unmarshal(r, &w)
|
|
}
|
|
|
|
// HideGeneralForumTopicOpts is the set of optional fields for Bot.HideGeneralForumTopic and Bot.HideGeneralForumTopicWithContext.
|
|
type HideGeneralForumTopicOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// HideGeneralForumTopic (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type HideGeneralForumTopicOpts): All optional parameters.
|
|
func (bot *Bot) HideGeneralForumTopic(chatId int64, opts *HideGeneralForumTopicOpts) (bool, error) {
|
|
return bot.HideGeneralForumTopicWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// HideGeneralForumTopicWithContext is the same as Bot.HideGeneralForumTopic, but with a context.Context parameter
|
|
func (bot *Bot) HideGeneralForumTopicWithContext(ctx context.Context, chatId int64, opts *HideGeneralForumTopicOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "hideGeneralForumTopic", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// LeaveChatOpts is the set of optional fields for Bot.LeaveChat and Bot.LeaveChatWithContext.
|
|
type LeaveChatOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// LeaveChat (https://core.telegram.org/bots/api#leavechat)
|
|
//
|
|
// Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type LeaveChatOpts): All optional parameters.
|
|
func (bot *Bot) LeaveChat(chatId int64, opts *LeaveChatOpts) (bool, error) {
|
|
return bot.LeaveChatWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// LeaveChatWithContext is the same as Bot.LeaveChat, but with a context.Context parameter
|
|
func (bot *Bot) LeaveChatWithContext(ctx context.Context, chatId int64, opts *LeaveChatOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "leaveChat", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// LogOutOpts is the set of optional fields for Bot.LogOut and Bot.LogOutWithContext.
|
|
type LogOutOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// LogOut (https://core.telegram.org/bots/api#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.
|
|
// - opts (type LogOutOpts): All optional parameters.
|
|
func (bot *Bot) LogOut(opts *LogOutOpts) (bool, error) {
|
|
return bot.LogOutWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// LogOutWithContext is the same as Bot.LogOut, but with a context.Context parameter
|
|
func (bot *Bot) LogOutWithContext(ctx context.Context, opts *LogOutOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "logOut", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// PinChatMessageOpts is the set of optional fields for Bot.PinChatMessage and Bot.PinChatMessageWithContext.
|
|
type PinChatMessageOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be pinned
|
|
BusinessConnectionId string
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// PinChatMessage (https://core.telegram.org/bots/api#pinchatmessage)
|
|
//
|
|
// Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - messageId (type int64): Identifier of a message to pin
|
|
// - opts (type PinChatMessageOpts): All optional parameters.
|
|
func (bot *Bot) PinChatMessage(chatId int64, messageId int64, opts *PinChatMessageOpts) (bool, error) {
|
|
return bot.PinChatMessageWithContext(context.Background(), chatId, messageId, opts)
|
|
}
|
|
|
|
// PinChatMessageWithContext is the same as Bot.PinChatMessage, but with a context.Context parameter
|
|
func (bot *Bot) PinChatMessageWithContext(ctx context.Context, chatId int64, messageId int64, opts *PinChatMessageOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["message_id"] = strconv.FormatInt(messageId, 10)
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "pinChatMessage", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// PromoteChatMemberOpts is the set of optional fields for Bot.PromoteChatMember and Bot.PromoteChatMemberWithContext.
|
|
type PromoteChatMemberOpts struct {
|
|
// Pass True if the administrator's presence in the chat is hidden
|
|
IsAnonymous bool
|
|
// Pass True if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode. Implied by any other administrator privilege.
|
|
CanManageChat bool
|
|
// Pass True if the administrator can delete messages of other users
|
|
CanDeleteMessages bool
|
|
// Pass True if the administrator can manage video chats
|
|
CanManageVideoChats bool
|
|
// Pass True if the administrator can restrict, ban or unban chat members, or access supergroup statistics
|
|
CanRestrictMembers bool
|
|
// 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
|
|
// Pass True if the administrator can change chat title, photo and other settings
|
|
CanChangeInfo bool
|
|
// Pass True if the administrator can invite new users to the chat
|
|
CanInviteUsers bool
|
|
// Pass True if the administrator can post stories to the chat
|
|
CanPostStories bool
|
|
// 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
|
|
// Pass True if the administrator can delete stories posted by other users
|
|
CanDeleteStories bool
|
|
// Pass True if the administrator can post messages in the channel, or access channel statistics; for channels only
|
|
CanPostMessages bool
|
|
// Pass True if the administrator can edit messages of other users and can pin messages; for channels only
|
|
CanEditMessages bool
|
|
// Pass True if the administrator can pin messages; for supergroups only
|
|
CanPinMessages bool
|
|
// Pass True if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only
|
|
CanManageTopics bool
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// PromoteChatMember (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - userId (type int64): Unique identifier of the target user
|
|
// - opts (type PromoteChatMemberOpts): All optional parameters.
|
|
func (bot *Bot) PromoteChatMember(chatId int64, userId int64, opts *PromoteChatMemberOpts) (bool, error) {
|
|
return bot.PromoteChatMemberWithContext(context.Background(), chatId, userId, opts)
|
|
}
|
|
|
|
// PromoteChatMemberWithContext is the same as Bot.PromoteChatMember, but with a context.Context parameter
|
|
func (bot *Bot) PromoteChatMemberWithContext(ctx context.Context, chatId int64, userId int64, opts *PromoteChatMemberOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
if opts != nil {
|
|
v["is_anonymous"] = strconv.FormatBool(opts.IsAnonymous)
|
|
v["can_manage_chat"] = strconv.FormatBool(opts.CanManageChat)
|
|
v["can_delete_messages"] = strconv.FormatBool(opts.CanDeleteMessages)
|
|
v["can_manage_video_chats"] = strconv.FormatBool(opts.CanManageVideoChats)
|
|
v["can_restrict_members"] = strconv.FormatBool(opts.CanRestrictMembers)
|
|
v["can_promote_members"] = strconv.FormatBool(opts.CanPromoteMembers)
|
|
v["can_change_info"] = strconv.FormatBool(opts.CanChangeInfo)
|
|
v["can_invite_users"] = strconv.FormatBool(opts.CanInviteUsers)
|
|
v["can_post_stories"] = strconv.FormatBool(opts.CanPostStories)
|
|
v["can_edit_stories"] = strconv.FormatBool(opts.CanEditStories)
|
|
v["can_delete_stories"] = strconv.FormatBool(opts.CanDeleteStories)
|
|
v["can_post_messages"] = strconv.FormatBool(opts.CanPostMessages)
|
|
v["can_edit_messages"] = strconv.FormatBool(opts.CanEditMessages)
|
|
v["can_pin_messages"] = strconv.FormatBool(opts.CanPinMessages)
|
|
v["can_manage_topics"] = strconv.FormatBool(opts.CanManageTopics)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "promoteChatMember", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// RefundStarPaymentOpts is the set of optional fields for Bot.RefundStarPayment and Bot.RefundStarPaymentWithContext.
|
|
type RefundStarPaymentOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// RefundStarPayment (https://core.telegram.org/bots/api#refundstarpayment)
|
|
//
|
|
// Refunds a successful payment in Telegram Stars. Returns True on success.
|
|
// - userId (type int64): Identifier of the user whose payment will be refunded
|
|
// - telegramPaymentChargeId (type string): Telegram payment identifier
|
|
// - opts (type RefundStarPaymentOpts): All optional parameters.
|
|
func (bot *Bot) RefundStarPayment(userId int64, telegramPaymentChargeId string, opts *RefundStarPaymentOpts) (bool, error) {
|
|
return bot.RefundStarPaymentWithContext(context.Background(), userId, telegramPaymentChargeId, opts)
|
|
}
|
|
|
|
// RefundStarPaymentWithContext is the same as Bot.RefundStarPayment, but with a context.Context parameter
|
|
func (bot *Bot) RefundStarPaymentWithContext(ctx context.Context, userId int64, telegramPaymentChargeId string, opts *RefundStarPaymentOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
v["telegram_payment_charge_id"] = telegramPaymentChargeId
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "refundStarPayment", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// ReopenForumTopicOpts is the set of optional fields for Bot.ReopenForumTopic and Bot.ReopenForumTopicWithContext.
|
|
type ReopenForumTopicOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// ReopenForumTopic (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - messageThreadId (type int64): Unique identifier for the target message thread of the forum topic
|
|
// - opts (type ReopenForumTopicOpts): All optional parameters.
|
|
func (bot *Bot) ReopenForumTopic(chatId int64, messageThreadId int64, opts *ReopenForumTopicOpts) (bool, error) {
|
|
return bot.ReopenForumTopicWithContext(context.Background(), chatId, messageThreadId, opts)
|
|
}
|
|
|
|
// ReopenForumTopicWithContext is the same as Bot.ReopenForumTopic, but with a context.Context parameter
|
|
func (bot *Bot) ReopenForumTopicWithContext(ctx context.Context, chatId int64, messageThreadId int64, opts *ReopenForumTopicOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["message_thread_id"] = strconv.FormatInt(messageThreadId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "reopenForumTopic", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// ReopenGeneralForumTopicOpts is the set of optional fields for Bot.ReopenGeneralForumTopic and Bot.ReopenGeneralForumTopicWithContext.
|
|
type ReopenGeneralForumTopicOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// ReopenGeneralForumTopic (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type ReopenGeneralForumTopicOpts): All optional parameters.
|
|
func (bot *Bot) ReopenGeneralForumTopic(chatId int64, opts *ReopenGeneralForumTopicOpts) (bool, error) {
|
|
return bot.ReopenGeneralForumTopicWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// ReopenGeneralForumTopicWithContext is the same as Bot.ReopenGeneralForumTopic, but with a context.Context parameter
|
|
func (bot *Bot) ReopenGeneralForumTopicWithContext(ctx context.Context, chatId int64, opts *ReopenGeneralForumTopicOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "reopenGeneralForumTopic", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// ReplaceStickerInSetOpts is the set of optional fields for Bot.ReplaceStickerInSet and Bot.ReplaceStickerInSetWithContext.
|
|
type ReplaceStickerInSetOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// ReplaceStickerInSet (https://core.telegram.org/bots/api#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.
|
|
// - userId (type int64): User identifier of the sticker set owner
|
|
// - name (type string): Sticker set name
|
|
// - oldSticker (type string): File identifier of the replaced sticker
|
|
// - sticker (type InputSticker): 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.
|
|
// - opts (type ReplaceStickerInSetOpts): All optional parameters.
|
|
func (bot *Bot) ReplaceStickerInSet(userId int64, name string, oldSticker string, sticker InputSticker, opts *ReplaceStickerInSetOpts) (bool, error) {
|
|
return bot.ReplaceStickerInSetWithContext(context.Background(), userId, name, oldSticker, sticker, opts)
|
|
}
|
|
|
|
// ReplaceStickerInSetWithContext is the same as Bot.ReplaceStickerInSet, but with a context.Context parameter
|
|
func (bot *Bot) ReplaceStickerInSetWithContext(ctx context.Context, userId int64, name string, oldSticker string, sticker InputSticker, opts *ReplaceStickerInSetOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
v["name"] = name
|
|
v["old_sticker"] = oldSticker
|
|
inputBs, err := sticker.InputParams("sticker", data)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field sticker: %w", err)
|
|
}
|
|
v["sticker"] = string(inputBs)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "replaceStickerInSet", v, data, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// RestrictChatMemberOpts is the set of optional fields for Bot.RestrictChatMember and Bot.RestrictChatMemberWithContext.
|
|
type RestrictChatMemberOpts struct {
|
|
// 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
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// RestrictChatMember (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - userId (type int64): Unique identifier of the target user
|
|
// - permissions (type ChatPermissions): A JSON-serialized object for new user permissions
|
|
// - opts (type RestrictChatMemberOpts): All optional parameters.
|
|
func (bot *Bot) RestrictChatMember(chatId int64, userId int64, permissions ChatPermissions, opts *RestrictChatMemberOpts) (bool, error) {
|
|
return bot.RestrictChatMemberWithContext(context.Background(), chatId, userId, permissions, opts)
|
|
}
|
|
|
|
// RestrictChatMemberWithContext is the same as Bot.RestrictChatMember, but with a context.Context parameter
|
|
func (bot *Bot) RestrictChatMemberWithContext(ctx context.Context, chatId int64, userId int64, permissions ChatPermissions, opts *RestrictChatMemberOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
bs, err := json.Marshal(permissions)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field permissions: %w", err)
|
|
}
|
|
v["permissions"] = string(bs)
|
|
if opts != nil {
|
|
v["use_independent_chat_permissions"] = strconv.FormatBool(opts.UseIndependentChatPermissions)
|
|
if opts.UntilDate != 0 {
|
|
v["until_date"] = strconv.FormatInt(opts.UntilDate, 10)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "restrictChatMember", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// RevokeChatInviteLinkOpts is the set of optional fields for Bot.RevokeChatInviteLink and Bot.RevokeChatInviteLinkWithContext.
|
|
type RevokeChatInviteLinkOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// RevokeChatInviteLink (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier of the target chat
|
|
// - inviteLink (type string): The invite link to revoke
|
|
// - opts (type RevokeChatInviteLinkOpts): All optional parameters.
|
|
func (bot *Bot) RevokeChatInviteLink(chatId int64, inviteLink string, opts *RevokeChatInviteLinkOpts) (*ChatInviteLink, error) {
|
|
return bot.RevokeChatInviteLinkWithContext(context.Background(), chatId, inviteLink, opts)
|
|
}
|
|
|
|
// RevokeChatInviteLinkWithContext is the same as Bot.RevokeChatInviteLink, but with a context.Context parameter
|
|
func (bot *Bot) RevokeChatInviteLinkWithContext(ctx context.Context, chatId int64, inviteLink string, opts *RevokeChatInviteLinkOpts) (*ChatInviteLink, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["invite_link"] = inviteLink
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "revokeChatInviteLink", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var c ChatInviteLink
|
|
return &c, json.Unmarshal(r, &c)
|
|
}
|
|
|
|
// SendAnimationOpts is the set of optional fields for Bot.SendAnimation and Bot.SendAnimationWithContext.
|
|
type SendAnimationOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Duration of sent animation in seconds
|
|
Duration int64
|
|
// Animation width
|
|
Width int64
|
|
// Animation height
|
|
Height int64
|
|
// 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: https://core.telegram.org/bots/api#sending-files
|
|
Thumbnail InputFile
|
|
// Animation caption (may also be used when resending animation by file_id), 0-1024 characters after entities parsing
|
|
Caption string
|
|
// Mode for parsing entities in the animation caption. See formatting options for more details.
|
|
ParseMode string
|
|
// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
|
|
CaptionEntities []MessageEntity
|
|
// Pass True, if the caption must be shown above the message media
|
|
ShowCaptionAboveMedia bool
|
|
// Pass True if the animation needs to be covered with a spoiler animation
|
|
HasSpoiler bool
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendAnimation (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - animation (type InputFileOrString): 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: https://core.telegram.org/bots/api#sending-files
|
|
// - opts (type SendAnimationOpts): All optional parameters.
|
|
func (bot *Bot) SendAnimation(chatId int64, animation InputFileOrString, opts *SendAnimationOpts) (*Message, error) {
|
|
return bot.SendAnimationWithContext(context.Background(), chatId, animation, opts)
|
|
}
|
|
|
|
// SendAnimationWithContext is the same as Bot.SendAnimation, but with a context.Context parameter
|
|
func (bot *Bot) SendAnimationWithContext(ctx context.Context, chatId int64, animation InputFileOrString, opts *SendAnimationOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if animation != nil {
|
|
err := animation.Attach("animation", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'animation' input file: %w", err)
|
|
}
|
|
v["animation"] = animation.getValue()
|
|
}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
if opts.Duration != 0 {
|
|
v["duration"] = strconv.FormatInt(opts.Duration, 10)
|
|
}
|
|
if opts.Width != 0 {
|
|
v["width"] = strconv.FormatInt(opts.Width, 10)
|
|
}
|
|
if opts.Height != 0 {
|
|
v["height"] = strconv.FormatInt(opts.Height, 10)
|
|
}
|
|
if opts.Thumbnail != nil {
|
|
err := opts.Thumbnail.Attach("thumbnail", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'thumbnail' input file: %w", err)
|
|
}
|
|
v["thumbnail"] = opts.Thumbnail.getValue()
|
|
}
|
|
v["caption"] = opts.Caption
|
|
v["parse_mode"] = opts.ParseMode
|
|
if opts.CaptionEntities != nil {
|
|
bs, err := json.Marshal(opts.CaptionEntities)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err)
|
|
}
|
|
v["caption_entities"] = string(bs)
|
|
}
|
|
v["show_caption_above_media"] = strconv.FormatBool(opts.ShowCaptionAboveMedia)
|
|
v["has_spoiler"] = strconv.FormatBool(opts.HasSpoiler)
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendAnimation", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendAudioOpts is the set of optional fields for Bot.SendAudio and Bot.SendAudioWithContext.
|
|
type SendAudioOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Audio caption, 0-1024 characters after entities parsing
|
|
Caption string
|
|
// Mode for parsing entities in the audio caption. See formatting options for more details.
|
|
ParseMode string
|
|
// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
|
|
CaptionEntities []MessageEntity
|
|
// Duration of the audio in seconds
|
|
Duration int64
|
|
// Performer
|
|
Performer string
|
|
// Track name
|
|
Title string
|
|
// 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: https://core.telegram.org/bots/api#sending-files
|
|
Thumbnail InputFile
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendAudio (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - audio (type InputFileOrString): 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: https://core.telegram.org/bots/api#sending-files
|
|
// - opts (type SendAudioOpts): All optional parameters.
|
|
func (bot *Bot) SendAudio(chatId int64, audio InputFileOrString, opts *SendAudioOpts) (*Message, error) {
|
|
return bot.SendAudioWithContext(context.Background(), chatId, audio, opts)
|
|
}
|
|
|
|
// SendAudioWithContext is the same as Bot.SendAudio, but with a context.Context parameter
|
|
func (bot *Bot) SendAudioWithContext(ctx context.Context, chatId int64, audio InputFileOrString, opts *SendAudioOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if audio != nil {
|
|
err := audio.Attach("audio", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'audio' input file: %w", err)
|
|
}
|
|
v["audio"] = audio.getValue()
|
|
}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["caption"] = opts.Caption
|
|
v["parse_mode"] = opts.ParseMode
|
|
if opts.CaptionEntities != nil {
|
|
bs, err := json.Marshal(opts.CaptionEntities)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err)
|
|
}
|
|
v["caption_entities"] = string(bs)
|
|
}
|
|
if opts.Duration != 0 {
|
|
v["duration"] = strconv.FormatInt(opts.Duration, 10)
|
|
}
|
|
v["performer"] = opts.Performer
|
|
v["title"] = opts.Title
|
|
if opts.Thumbnail != nil {
|
|
err := opts.Thumbnail.Attach("thumbnail", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'thumbnail' input file: %w", err)
|
|
}
|
|
v["thumbnail"] = opts.Thumbnail.getValue()
|
|
}
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendAudio", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendChatActionOpts is the set of optional fields for Bot.SendChatAction and Bot.SendChatActionWithContext.
|
|
type SendChatActionOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the action will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread; for supergroups only
|
|
MessageThreadId int64
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendChatAction (https://core.telegram.org/bots/api#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.
|
|
// We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - action (type string): 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.
|
|
// - opts (type SendChatActionOpts): All optional parameters.
|
|
func (bot *Bot) SendChatAction(chatId int64, action string, opts *SendChatActionOpts) (bool, error) {
|
|
return bot.SendChatActionWithContext(context.Background(), chatId, action, opts)
|
|
}
|
|
|
|
// SendChatActionWithContext is the same as Bot.SendChatAction, but with a context.Context parameter
|
|
func (bot *Bot) SendChatActionWithContext(ctx context.Context, chatId int64, action string, opts *SendChatActionOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["action"] = action
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendChatAction", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SendContactOpts is the set of optional fields for Bot.SendContact and Bot.SendContactWithContext.
|
|
type SendContactOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Contact's last name
|
|
LastName string
|
|
// Additional data about the contact in the form of a vCard, 0-2048 bytes
|
|
Vcard string
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendContact (https://core.telegram.org/bots/api#sendcontact)
|
|
//
|
|
// Use this method to send phone contacts. On success, the sent Message is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - phoneNumber (type string): Contact's phone number
|
|
// - firstName (type string): Contact's first name
|
|
// - opts (type SendContactOpts): All optional parameters.
|
|
func (bot *Bot) SendContact(chatId int64, phoneNumber string, firstName string, opts *SendContactOpts) (*Message, error) {
|
|
return bot.SendContactWithContext(context.Background(), chatId, phoneNumber, firstName, opts)
|
|
}
|
|
|
|
// SendContactWithContext is the same as Bot.SendContact, but with a context.Context parameter
|
|
func (bot *Bot) SendContactWithContext(ctx context.Context, chatId int64, phoneNumber string, firstName string, opts *SendContactOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["phone_number"] = phoneNumber
|
|
v["first_name"] = firstName
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["last_name"] = opts.LastName
|
|
v["vcard"] = opts.Vcard
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendContact", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendDiceOpts is the set of optional fields for Bot.SendDice and Bot.SendDiceWithContext.
|
|
type SendDiceOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// 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 string
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendDice (https://core.telegram.org/bots/api#senddice)
|
|
//
|
|
// Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type SendDiceOpts): All optional parameters.
|
|
func (bot *Bot) SendDice(chatId int64, opts *SendDiceOpts) (*Message, error) {
|
|
return bot.SendDiceWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// SendDiceWithContext is the same as Bot.SendDice, but with a context.Context parameter
|
|
func (bot *Bot) SendDiceWithContext(ctx context.Context, chatId int64, opts *SendDiceOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["emoji"] = opts.Emoji
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendDice", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendDocumentOpts is the set of optional fields for Bot.SendDocument and Bot.SendDocumentWithContext.
|
|
type SendDocumentOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// 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: https://core.telegram.org/bots/api#sending-files
|
|
Thumbnail InputFile
|
|
// Document caption (may also be used when resending documents by file_id), 0-1024 characters after entities parsing
|
|
Caption string
|
|
// Mode for parsing entities in the document caption. See formatting options for more details.
|
|
ParseMode string
|
|
// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
|
|
CaptionEntities []MessageEntity
|
|
// Disables automatic server-side content type detection for files uploaded using multipart/form-data
|
|
DisableContentTypeDetection bool
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendDocument (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - document (type InputFileOrString): 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: https://core.telegram.org/bots/api#sending-files
|
|
// - opts (type SendDocumentOpts): All optional parameters.
|
|
func (bot *Bot) SendDocument(chatId int64, document InputFileOrString, opts *SendDocumentOpts) (*Message, error) {
|
|
return bot.SendDocumentWithContext(context.Background(), chatId, document, opts)
|
|
}
|
|
|
|
// SendDocumentWithContext is the same as Bot.SendDocument, but with a context.Context parameter
|
|
func (bot *Bot) SendDocumentWithContext(ctx context.Context, chatId int64, document InputFileOrString, opts *SendDocumentOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if document != nil {
|
|
err := document.Attach("document", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'document' input file: %w", err)
|
|
}
|
|
v["document"] = document.getValue()
|
|
}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
if opts.Thumbnail != nil {
|
|
err := opts.Thumbnail.Attach("thumbnail", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'thumbnail' input file: %w", err)
|
|
}
|
|
v["thumbnail"] = opts.Thumbnail.getValue()
|
|
}
|
|
v["caption"] = opts.Caption
|
|
v["parse_mode"] = opts.ParseMode
|
|
if opts.CaptionEntities != nil {
|
|
bs, err := json.Marshal(opts.CaptionEntities)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err)
|
|
}
|
|
v["caption_entities"] = string(bs)
|
|
}
|
|
v["disable_content_type_detection"] = strconv.FormatBool(opts.DisableContentTypeDetection)
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendDocument", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendGameOpts is the set of optional fields for Bot.SendGame and Bot.SendGameWithContext.
|
|
type SendGameOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendGame (https://core.telegram.org/bots/api#sendgame)
|
|
//
|
|
// Use this method to send a game. On success, the sent Message is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - gameShortName (type string): Short name of the game, serves as the unique identifier for the game. Set up your games via @BotFather.
|
|
// - opts (type SendGameOpts): All optional parameters.
|
|
func (bot *Bot) SendGame(chatId int64, gameShortName string, opts *SendGameOpts) (*Message, error) {
|
|
return bot.SendGameWithContext(context.Background(), chatId, gameShortName, opts)
|
|
}
|
|
|
|
// SendGameWithContext is the same as Bot.SendGame, but with a context.Context parameter
|
|
func (bot *Bot) SendGameWithContext(ctx context.Context, chatId int64, gameShortName string, opts *SendGameOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["game_short_name"] = gameShortName
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendGame", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendInvoiceOpts is the set of optional fields for Bot.SendInvoice and Bot.SendInvoiceWithContext.
|
|
type SendInvoiceOpts struct {
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
|
|
ProviderToken string
|
|
// 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
|
|
// 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
|
|
// 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-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
|
|
// 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
|
|
// Photo size in bytes
|
|
PhotoSize int64
|
|
// Photo width
|
|
PhotoWidth int64
|
|
// Photo height
|
|
PhotoHeight int64
|
|
// Pass True if you require the user's full name to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedName bool
|
|
// Pass True if you require the user's phone number to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedPhoneNumber bool
|
|
// Pass True if you require the user's email address to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedEmail bool
|
|
// Pass True if you require the user's shipping address to complete the order. Ignored for payments in Telegram Stars.
|
|
NeedShippingAddress bool
|
|
// Pass True if the user's phone number should be sent to the provider. Ignored for payments in Telegram Stars.
|
|
SendPhoneNumberToProvider bool
|
|
// Pass True if the user's email address should be sent to the provider. Ignored for payments in Telegram Stars.
|
|
SendEmailToProvider bool
|
|
// Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars.
|
|
IsFlexible bool
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendInvoice (https://core.telegram.org/bots/api#sendinvoice)
|
|
//
|
|
// Use this method to send invoices. On success, the sent Message is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - title (type string): Product name, 1-32 characters
|
|
// - description (type string): Product description, 1-255 characters
|
|
// - payload (type string): Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
|
|
// - currency (type string): Three-letter ISO 4217 currency code, see more on currencies. Pass "XTR" for payments in Telegram Stars.
|
|
// - prices (type []LabeledPrice): 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.
|
|
// - opts (type SendInvoiceOpts): All optional parameters.
|
|
func (bot *Bot) SendInvoice(chatId int64, title string, description string, payload string, currency string, prices []LabeledPrice, opts *SendInvoiceOpts) (*Message, error) {
|
|
return bot.SendInvoiceWithContext(context.Background(), chatId, title, description, payload, currency, prices, opts)
|
|
}
|
|
|
|
// SendInvoiceWithContext is the same as Bot.SendInvoice, but with a context.Context parameter
|
|
func (bot *Bot) SendInvoiceWithContext(ctx context.Context, chatId int64, title string, description string, payload string, currency string, prices []LabeledPrice, opts *SendInvoiceOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["title"] = title
|
|
v["description"] = description
|
|
v["payload"] = payload
|
|
v["currency"] = currency
|
|
if prices != nil {
|
|
bs, err := json.Marshal(prices)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field prices: %w", err)
|
|
}
|
|
v["prices"] = string(bs)
|
|
}
|
|
if opts != nil {
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["provider_token"] = opts.ProviderToken
|
|
if opts.MaxTipAmount != 0 {
|
|
v["max_tip_amount"] = strconv.FormatInt(opts.MaxTipAmount, 10)
|
|
}
|
|
if opts.SuggestedTipAmounts != nil {
|
|
bs, err := json.Marshal(opts.SuggestedTipAmounts)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field suggested_tip_amounts: %w", err)
|
|
}
|
|
v["suggested_tip_amounts"] = string(bs)
|
|
}
|
|
v["start_parameter"] = opts.StartParameter
|
|
v["provider_data"] = opts.ProviderData
|
|
v["photo_url"] = opts.PhotoUrl
|
|
if opts.PhotoSize != 0 {
|
|
v["photo_size"] = strconv.FormatInt(opts.PhotoSize, 10)
|
|
}
|
|
if opts.PhotoWidth != 0 {
|
|
v["photo_width"] = strconv.FormatInt(opts.PhotoWidth, 10)
|
|
}
|
|
if opts.PhotoHeight != 0 {
|
|
v["photo_height"] = strconv.FormatInt(opts.PhotoHeight, 10)
|
|
}
|
|
v["need_name"] = strconv.FormatBool(opts.NeedName)
|
|
v["need_phone_number"] = strconv.FormatBool(opts.NeedPhoneNumber)
|
|
v["need_email"] = strconv.FormatBool(opts.NeedEmail)
|
|
v["need_shipping_address"] = strconv.FormatBool(opts.NeedShippingAddress)
|
|
v["send_phone_number_to_provider"] = strconv.FormatBool(opts.SendPhoneNumberToProvider)
|
|
v["send_email_to_provider"] = strconv.FormatBool(opts.SendEmailToProvider)
|
|
v["is_flexible"] = strconv.FormatBool(opts.IsFlexible)
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendInvoice", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendLocationOpts is the set of optional fields for Bot.SendLocation and Bot.SendLocationWithContext.
|
|
type SendLocationOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// The radius of uncertainty for the location, measured in meters; 0-1500
|
|
HorizontalAccuracy float64
|
|
// 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
|
|
// For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
|
|
Heading int64
|
|
// 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
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendLocation (https://core.telegram.org/bots/api#sendlocation)
|
|
//
|
|
// Use this method to send point on the map. On success, the sent Message is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - latitude (type float64): Latitude of the location
|
|
// - longitude (type float64): Longitude of the location
|
|
// - opts (type SendLocationOpts): All optional parameters.
|
|
func (bot *Bot) SendLocation(chatId int64, latitude float64, longitude float64, opts *SendLocationOpts) (*Message, error) {
|
|
return bot.SendLocationWithContext(context.Background(), chatId, latitude, longitude, opts)
|
|
}
|
|
|
|
// SendLocationWithContext is the same as Bot.SendLocation, but with a context.Context parameter
|
|
func (bot *Bot) SendLocationWithContext(ctx context.Context, chatId int64, latitude float64, longitude float64, opts *SendLocationOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["latitude"] = strconv.FormatFloat(latitude, 'f', -1, 64)
|
|
v["longitude"] = strconv.FormatFloat(longitude, 'f', -1, 64)
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
if opts.HorizontalAccuracy != 0.0 {
|
|
v["horizontal_accuracy"] = strconv.FormatFloat(opts.HorizontalAccuracy, 'f', -1, 64)
|
|
}
|
|
if opts.LivePeriod != 0 {
|
|
v["live_period"] = strconv.FormatInt(opts.LivePeriod, 10)
|
|
}
|
|
if opts.Heading != 0 {
|
|
v["heading"] = strconv.FormatInt(opts.Heading, 10)
|
|
}
|
|
if opts.ProximityAlertRadius != 0 {
|
|
v["proximity_alert_radius"] = strconv.FormatInt(opts.ProximityAlertRadius, 10)
|
|
}
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendLocation", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendMediaGroupOpts is the set of optional fields for Bot.SendMediaGroup and Bot.SendMediaGroupWithContext.
|
|
type SendMediaGroupOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Sends messages silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent messages from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendMediaGroup (https://core.telegram.org/bots/api#sendmediagroup)
|
|
//
|
|
// Use this method to send a group of 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 Messages that were sent is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - media (type []InputMedia): A JSON-serialized array describing messages to be sent, must include 2-10 items
|
|
// - opts (type SendMediaGroupOpts): All optional parameters.
|
|
func (bot *Bot) SendMediaGroup(chatId int64, media []InputMedia, opts *SendMediaGroupOpts) ([]Message, error) {
|
|
return bot.SendMediaGroupWithContext(context.Background(), chatId, media, opts)
|
|
}
|
|
|
|
// SendMediaGroupWithContext is the same as Bot.SendMediaGroup, but with a context.Context parameter
|
|
func (bot *Bot) SendMediaGroupWithContext(ctx context.Context, chatId int64, media []InputMedia, opts *SendMediaGroupOpts) ([]Message, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if media != nil {
|
|
var rawList []json.RawMessage
|
|
for idx, im := range media {
|
|
inputBs, err := im.InputParams("media"+strconv.Itoa(idx), data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal list item %d for field media: %w", idx, err)
|
|
}
|
|
rawList = append(rawList, inputBs)
|
|
}
|
|
bs, err := json.Marshal(rawList)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal raw json list for field: media %w", err)
|
|
}
|
|
v["media"] = string(bs)
|
|
}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendMediaGroup", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m []Message
|
|
return m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendMessageOpts is the set of optional fields for Bot.SendMessage and Bot.SendMessageWithContext.
|
|
type SendMessageOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Mode for parsing entities in the message text. See formatting options for more details.
|
|
ParseMode string
|
|
// A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode
|
|
Entities []MessageEntity
|
|
// Link preview generation options for the message
|
|
LinkPreviewOptions *LinkPreviewOptions
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendMessage (https://core.telegram.org/bots/api#sendmessage)
|
|
//
|
|
// Use this method to send text messages. On success, the sent Message is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - text (type string): Text of the message to be sent, 1-4096 characters after entities parsing
|
|
// - opts (type SendMessageOpts): All optional parameters.
|
|
func (bot *Bot) SendMessage(chatId int64, text string, opts *SendMessageOpts) (*Message, error) {
|
|
return bot.SendMessageWithContext(context.Background(), chatId, text, opts)
|
|
}
|
|
|
|
// SendMessageWithContext is the same as Bot.SendMessage, but with a context.Context parameter
|
|
func (bot *Bot) SendMessageWithContext(ctx context.Context, chatId int64, text string, opts *SendMessageOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["text"] = text
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["parse_mode"] = opts.ParseMode
|
|
if opts.Entities != nil {
|
|
bs, err := json.Marshal(opts.Entities)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field entities: %w", err)
|
|
}
|
|
v["entities"] = string(bs)
|
|
}
|
|
if opts.LinkPreviewOptions != nil {
|
|
bs, err := json.Marshal(opts.LinkPreviewOptions)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field link_preview_options: %w", err)
|
|
}
|
|
v["link_preview_options"] = string(bs)
|
|
}
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendMessage", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendPaidMediaOpts is the set of optional fields for Bot.SendPaidMedia and Bot.SendPaidMediaWithContext.
|
|
type SendPaidMediaOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
|
|
Payload string
|
|
// Media caption, 0-1024 characters after entities parsing
|
|
Caption string
|
|
// Mode for parsing entities in the media caption. See formatting options for more details.
|
|
ParseMode string
|
|
// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
|
|
CaptionEntities []MessageEntity
|
|
// Pass True, if the caption must be shown above the message media
|
|
ShowCaptionAboveMedia bool
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendPaidMedia (https://core.telegram.org/bots/api#sendpaidmedia)
|
|
//
|
|
// Use this method to send paid media. On success, the sent Message is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat. 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.
|
|
// - starCount (type int64): The number of Telegram Stars that must be paid to buy access to the media; 1-2500
|
|
// - media (type []InputPaidMedia): A JSON-serialized array describing the media to be sent; up to 10 items
|
|
// - opts (type SendPaidMediaOpts): All optional parameters.
|
|
func (bot *Bot) SendPaidMedia(chatId int64, starCount int64, media []InputPaidMedia, opts *SendPaidMediaOpts) (*Message, error) {
|
|
return bot.SendPaidMediaWithContext(context.Background(), chatId, starCount, media, opts)
|
|
}
|
|
|
|
// SendPaidMediaWithContext is the same as Bot.SendPaidMedia, but with a context.Context parameter
|
|
func (bot *Bot) SendPaidMediaWithContext(ctx context.Context, chatId int64, starCount int64, media []InputPaidMedia, opts *SendPaidMediaOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["star_count"] = strconv.FormatInt(starCount, 10)
|
|
if media != nil {
|
|
var rawList []json.RawMessage
|
|
for idx, im := range media {
|
|
inputBs, err := im.InputParams("media"+strconv.Itoa(idx), data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal list item %d for field media: %w", idx, err)
|
|
}
|
|
rawList = append(rawList, inputBs)
|
|
}
|
|
bs, err := json.Marshal(rawList)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal raw json list for field: media %w", err)
|
|
}
|
|
v["media"] = string(bs)
|
|
}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
v["payload"] = opts.Payload
|
|
v["caption"] = opts.Caption
|
|
v["parse_mode"] = opts.ParseMode
|
|
if opts.CaptionEntities != nil {
|
|
bs, err := json.Marshal(opts.CaptionEntities)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err)
|
|
}
|
|
v["caption_entities"] = string(bs)
|
|
}
|
|
v["show_caption_above_media"] = strconv.FormatBool(opts.ShowCaptionAboveMedia)
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendPaidMedia", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendPhotoOpts is the set of optional fields for Bot.SendPhoto and Bot.SendPhotoWithContext.
|
|
type SendPhotoOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Photo caption (may also be used when resending photos by file_id), 0-1024 characters after entities parsing
|
|
Caption string
|
|
// Mode for parsing entities in the photo caption. See formatting options for more details.
|
|
ParseMode string
|
|
// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
|
|
CaptionEntities []MessageEntity
|
|
// Pass True, if the caption must be shown above the message media
|
|
ShowCaptionAboveMedia bool
|
|
// Pass True if the photo needs to be covered with a spoiler animation
|
|
HasSpoiler bool
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendPhoto (https://core.telegram.org/bots/api#sendphoto)
|
|
//
|
|
// Use this method to send photos. On success, the sent Message is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - photo (type InputFileOrString): 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: https://core.telegram.org/bots/api#sending-files
|
|
// - opts (type SendPhotoOpts): All optional parameters.
|
|
func (bot *Bot) SendPhoto(chatId int64, photo InputFileOrString, opts *SendPhotoOpts) (*Message, error) {
|
|
return bot.SendPhotoWithContext(context.Background(), chatId, photo, opts)
|
|
}
|
|
|
|
// SendPhotoWithContext is the same as Bot.SendPhoto, but with a context.Context parameter
|
|
func (bot *Bot) SendPhotoWithContext(ctx context.Context, chatId int64, photo InputFileOrString, opts *SendPhotoOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if photo != nil {
|
|
err := photo.Attach("photo", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'photo' input file: %w", err)
|
|
}
|
|
v["photo"] = photo.getValue()
|
|
}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["caption"] = opts.Caption
|
|
v["parse_mode"] = opts.ParseMode
|
|
if opts.CaptionEntities != nil {
|
|
bs, err := json.Marshal(opts.CaptionEntities)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err)
|
|
}
|
|
v["caption_entities"] = string(bs)
|
|
}
|
|
v["show_caption_above_media"] = strconv.FormatBool(opts.ShowCaptionAboveMedia)
|
|
v["has_spoiler"] = strconv.FormatBool(opts.HasSpoiler)
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendPhoto", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendPollOpts is the set of optional fields for Bot.SendPoll and Bot.SendPollWithContext.
|
|
type SendPollOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Mode for parsing entities in the question. See formatting options for more details. Currently, only custom emoji entities are allowed
|
|
QuestionParseMode string
|
|
// A JSON-serialized list of special entities that appear in the poll question. It can be specified instead of question_parse_mode
|
|
QuestionEntities []MessageEntity
|
|
// True, if the poll needs to be anonymous, defaults to True
|
|
IsAnonymous bool
|
|
// Poll type, "quiz" or "regular", defaults to "regular"
|
|
Type string
|
|
// True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False
|
|
AllowsMultipleAnswers bool
|
|
// 0-based identifier of the correct answer option, required for polls in quiz mode
|
|
CorrectOptionId int64
|
|
// 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
|
|
// Mode for parsing entities in the explanation. See formatting options for more details.
|
|
ExplanationParseMode string
|
|
// A JSON-serialized list of special entities that appear in the poll explanation. It can be specified instead of explanation_parse_mode
|
|
ExplanationEntities []MessageEntity
|
|
// Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date.
|
|
OpenPeriod int64
|
|
// Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with open_period.
|
|
CloseDate int64
|
|
// Pass True if the poll needs to be immediately closed. This can be useful for poll preview.
|
|
IsClosed bool
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendPoll (https://core.telegram.org/bots/api#sendpoll)
|
|
//
|
|
// Use this method to send a native poll. On success, the sent Message is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - question (type string): Poll question, 1-300 characters
|
|
// - options (type []InputPollOption): A JSON-serialized list of 2-10 answer options
|
|
// - opts (type SendPollOpts): All optional parameters.
|
|
func (bot *Bot) SendPoll(chatId int64, question string, options []InputPollOption, opts *SendPollOpts) (*Message, error) {
|
|
return bot.SendPollWithContext(context.Background(), chatId, question, options, opts)
|
|
}
|
|
|
|
// SendPollWithContext is the same as Bot.SendPoll, but with a context.Context parameter
|
|
func (bot *Bot) SendPollWithContext(ctx context.Context, chatId int64, question string, options []InputPollOption, opts *SendPollOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["question"] = question
|
|
if options != nil {
|
|
bs, err := json.Marshal(options)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field options: %w", err)
|
|
}
|
|
v["options"] = string(bs)
|
|
}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["question_parse_mode"] = opts.QuestionParseMode
|
|
if opts.QuestionEntities != nil {
|
|
bs, err := json.Marshal(opts.QuestionEntities)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field question_entities: %w", err)
|
|
}
|
|
v["question_entities"] = string(bs)
|
|
}
|
|
v["is_anonymous"] = strconv.FormatBool(opts.IsAnonymous)
|
|
v["type"] = opts.Type
|
|
v["allows_multiple_answers"] = strconv.FormatBool(opts.AllowsMultipleAnswers)
|
|
if opts.Type == "quiz" {
|
|
// correct_option_id should always be set when the type is "quiz" - it doesnt need to be set for type "regular".
|
|
v["correct_option_id"] = strconv.FormatInt(opts.CorrectOptionId, 10)
|
|
}
|
|
v["explanation"] = opts.Explanation
|
|
v["explanation_parse_mode"] = opts.ExplanationParseMode
|
|
if opts.ExplanationEntities != nil {
|
|
bs, err := json.Marshal(opts.ExplanationEntities)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field explanation_entities: %w", err)
|
|
}
|
|
v["explanation_entities"] = string(bs)
|
|
}
|
|
if opts.OpenPeriod != 0 {
|
|
v["open_period"] = strconv.FormatInt(opts.OpenPeriod, 10)
|
|
}
|
|
if opts.CloseDate != 0 {
|
|
v["close_date"] = strconv.FormatInt(opts.CloseDate, 10)
|
|
}
|
|
v["is_closed"] = strconv.FormatBool(opts.IsClosed)
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendPoll", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendStickerOpts is the set of optional fields for Bot.SendSticker and Bot.SendStickerWithContext.
|
|
type SendStickerOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Emoji associated with the sticker; only for just uploaded stickers
|
|
Emoji string
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendSticker (https://core.telegram.org/bots/api#sendsticker)
|
|
//
|
|
// Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - sticker (type InputFileOrString): 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: https://core.telegram.org/bots/api#sending-files. Video and animated stickers can't be sent via an HTTP URL.
|
|
// - opts (type SendStickerOpts): All optional parameters.
|
|
func (bot *Bot) SendSticker(chatId int64, sticker InputFileOrString, opts *SendStickerOpts) (*Message, error) {
|
|
return bot.SendStickerWithContext(context.Background(), chatId, sticker, opts)
|
|
}
|
|
|
|
// SendStickerWithContext is the same as Bot.SendSticker, but with a context.Context parameter
|
|
func (bot *Bot) SendStickerWithContext(ctx context.Context, chatId int64, sticker InputFileOrString, opts *SendStickerOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if sticker != nil {
|
|
err := sticker.Attach("sticker", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'sticker' input file: %w", err)
|
|
}
|
|
v["sticker"] = sticker.getValue()
|
|
}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["emoji"] = opts.Emoji
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendSticker", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendVenueOpts is the set of optional fields for Bot.SendVenue and Bot.SendVenueWithContext.
|
|
type SendVenueOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Foursquare identifier of the venue
|
|
FoursquareId string
|
|
// Foursquare type of the venue, if known. (For example, "arts_entertainment/default", "arts_entertainment/aquarium" or "food/icecream".)
|
|
FoursquareType string
|
|
// Google Places identifier of the venue
|
|
GooglePlaceId string
|
|
// Google Places type of the venue. (See supported types.)
|
|
GooglePlaceType string
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendVenue (https://core.telegram.org/bots/api#sendvenue)
|
|
//
|
|
// Use this method to send information about a venue. On success, the sent Message is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - latitude (type float64): Latitude of the venue
|
|
// - longitude (type float64): Longitude of the venue
|
|
// - title (type string): Name of the venue
|
|
// - address (type string): Address of the venue
|
|
// - opts (type SendVenueOpts): All optional parameters.
|
|
func (bot *Bot) SendVenue(chatId int64, latitude float64, longitude float64, title string, address string, opts *SendVenueOpts) (*Message, error) {
|
|
return bot.SendVenueWithContext(context.Background(), chatId, latitude, longitude, title, address, opts)
|
|
}
|
|
|
|
// SendVenueWithContext is the same as Bot.SendVenue, but with a context.Context parameter
|
|
func (bot *Bot) SendVenueWithContext(ctx context.Context, chatId int64, latitude float64, longitude float64, title string, address string, opts *SendVenueOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["latitude"] = strconv.FormatFloat(latitude, 'f', -1, 64)
|
|
v["longitude"] = strconv.FormatFloat(longitude, 'f', -1, 64)
|
|
v["title"] = title
|
|
v["address"] = address
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["foursquare_id"] = opts.FoursquareId
|
|
v["foursquare_type"] = opts.FoursquareType
|
|
v["google_place_id"] = opts.GooglePlaceId
|
|
v["google_place_type"] = opts.GooglePlaceType
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendVenue", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendVideoOpts is the set of optional fields for Bot.SendVideo and Bot.SendVideoWithContext.
|
|
type SendVideoOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Duration of sent video in seconds
|
|
Duration int64
|
|
// Video width
|
|
Width int64
|
|
// Video height
|
|
Height int64
|
|
// 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: https://core.telegram.org/bots/api#sending-files
|
|
Thumbnail InputFile
|
|
// Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing
|
|
Caption string
|
|
// Mode for parsing entities in the video caption. See formatting options for more details.
|
|
ParseMode string
|
|
// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
|
|
CaptionEntities []MessageEntity
|
|
// Pass True, if the caption must be shown above the message media
|
|
ShowCaptionAboveMedia bool
|
|
// Pass True if the video needs to be covered with a spoiler animation
|
|
HasSpoiler bool
|
|
// Pass True if the uploaded video is suitable for streaming
|
|
SupportsStreaming bool
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendVideo (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - video (type InputFileOrString): 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: https://core.telegram.org/bots/api#sending-files
|
|
// - opts (type SendVideoOpts): All optional parameters.
|
|
func (bot *Bot) SendVideo(chatId int64, video InputFileOrString, opts *SendVideoOpts) (*Message, error) {
|
|
return bot.SendVideoWithContext(context.Background(), chatId, video, opts)
|
|
}
|
|
|
|
// SendVideoWithContext is the same as Bot.SendVideo, but with a context.Context parameter
|
|
func (bot *Bot) SendVideoWithContext(ctx context.Context, chatId int64, video InputFileOrString, opts *SendVideoOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if video != nil {
|
|
err := video.Attach("video", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'video' input file: %w", err)
|
|
}
|
|
v["video"] = video.getValue()
|
|
}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
if opts.Duration != 0 {
|
|
v["duration"] = strconv.FormatInt(opts.Duration, 10)
|
|
}
|
|
if opts.Width != 0 {
|
|
v["width"] = strconv.FormatInt(opts.Width, 10)
|
|
}
|
|
if opts.Height != 0 {
|
|
v["height"] = strconv.FormatInt(opts.Height, 10)
|
|
}
|
|
if opts.Thumbnail != nil {
|
|
err := opts.Thumbnail.Attach("thumbnail", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'thumbnail' input file: %w", err)
|
|
}
|
|
v["thumbnail"] = opts.Thumbnail.getValue()
|
|
}
|
|
v["caption"] = opts.Caption
|
|
v["parse_mode"] = opts.ParseMode
|
|
if opts.CaptionEntities != nil {
|
|
bs, err := json.Marshal(opts.CaptionEntities)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err)
|
|
}
|
|
v["caption_entities"] = string(bs)
|
|
}
|
|
v["show_caption_above_media"] = strconv.FormatBool(opts.ShowCaptionAboveMedia)
|
|
v["has_spoiler"] = strconv.FormatBool(opts.HasSpoiler)
|
|
v["supports_streaming"] = strconv.FormatBool(opts.SupportsStreaming)
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendVideo", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendVideoNoteOpts is the set of optional fields for Bot.SendVideoNote and Bot.SendVideoNoteWithContext.
|
|
type SendVideoNoteOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Duration of sent video in seconds
|
|
Duration int64
|
|
// Video width and height, i.e. diameter of the video message
|
|
Length int64
|
|
// 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: https://core.telegram.org/bots/api#sending-files
|
|
Thumbnail InputFile
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendVideoNote (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - videoNote (type InputFileOrString): 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: https://core.telegram.org/bots/api#sending-files. Sending video notes by a URL is currently unsupported
|
|
// - opts (type SendVideoNoteOpts): All optional parameters.
|
|
func (bot *Bot) SendVideoNote(chatId int64, videoNote InputFileOrString, opts *SendVideoNoteOpts) (*Message, error) {
|
|
return bot.SendVideoNoteWithContext(context.Background(), chatId, videoNote, opts)
|
|
}
|
|
|
|
// SendVideoNoteWithContext is the same as Bot.SendVideoNote, but with a context.Context parameter
|
|
func (bot *Bot) SendVideoNoteWithContext(ctx context.Context, chatId int64, videoNote InputFileOrString, opts *SendVideoNoteOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if videoNote != nil {
|
|
err := videoNote.Attach("video_note", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'video_note' input file: %w", err)
|
|
}
|
|
v["video_note"] = videoNote.getValue()
|
|
}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
if opts.Duration != 0 {
|
|
v["duration"] = strconv.FormatInt(opts.Duration, 10)
|
|
}
|
|
if opts.Length != 0 {
|
|
v["length"] = strconv.FormatInt(opts.Length, 10)
|
|
}
|
|
if opts.Thumbnail != nil {
|
|
err := opts.Thumbnail.Attach("thumbnail", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'thumbnail' input file: %w", err)
|
|
}
|
|
v["thumbnail"] = opts.Thumbnail.getValue()
|
|
}
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendVideoNote", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SendVoiceOpts is the set of optional fields for Bot.SendVoice and Bot.SendVoiceWithContext.
|
|
type SendVoiceOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be sent
|
|
BusinessConnectionId string
|
|
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
|
MessageThreadId int64
|
|
// Voice message caption, 0-1024 characters after entities parsing
|
|
Caption string
|
|
// Mode for parsing entities in the voice message caption. See formatting options for more details.
|
|
ParseMode string
|
|
// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
|
|
CaptionEntities []MessageEntity
|
|
// Duration of the voice message in seconds
|
|
Duration int64
|
|
// Sends the message silently. Users will receive a notification with no sound.
|
|
DisableNotification bool
|
|
// Protects the contents of the sent message from forwarding and saving
|
|
ProtectContent bool
|
|
// 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
|
|
// Unique identifier of the message effect to be added to the message; for private chats only
|
|
MessageEffectId string
|
|
// Description of the message to reply to
|
|
ReplyParameters *ReplyParameters
|
|
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
ReplyMarkup ReplyMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SendVoice (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - voice (type InputFileOrString): 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: https://core.telegram.org/bots/api#sending-files
|
|
// - opts (type SendVoiceOpts): All optional parameters.
|
|
func (bot *Bot) SendVoice(chatId int64, voice InputFileOrString, opts *SendVoiceOpts) (*Message, error) {
|
|
return bot.SendVoiceWithContext(context.Background(), chatId, voice, opts)
|
|
}
|
|
|
|
// SendVoiceWithContext is the same as Bot.SendVoice, but with a context.Context parameter
|
|
func (bot *Bot) SendVoiceWithContext(ctx context.Context, chatId int64, voice InputFileOrString, opts *SendVoiceOpts) (*Message, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if voice != nil {
|
|
err := voice.Attach("voice", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'voice' input file: %w", err)
|
|
}
|
|
v["voice"] = voice.getValue()
|
|
}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageThreadId != 0 {
|
|
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
|
|
}
|
|
v["caption"] = opts.Caption
|
|
v["parse_mode"] = opts.ParseMode
|
|
if opts.CaptionEntities != nil {
|
|
bs, err := json.Marshal(opts.CaptionEntities)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err)
|
|
}
|
|
v["caption_entities"] = string(bs)
|
|
}
|
|
if opts.Duration != 0 {
|
|
v["duration"] = strconv.FormatInt(opts.Duration, 10)
|
|
}
|
|
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
|
|
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
|
|
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
|
|
v["message_effect_id"] = opts.MessageEffectId
|
|
if opts.ReplyParameters != nil {
|
|
bs, err := json.Marshal(opts.ReplyParameters)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
|
|
}
|
|
v["reply_parameters"] = string(bs)
|
|
}
|
|
if opts.ReplyMarkup != nil {
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "sendVoice", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var m Message
|
|
return &m, json.Unmarshal(r, &m)
|
|
}
|
|
|
|
// SetChatAdministratorCustomTitleOpts is the set of optional fields for Bot.SetChatAdministratorCustomTitle and Bot.SetChatAdministratorCustomTitleWithContext.
|
|
type SetChatAdministratorCustomTitleOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetChatAdministratorCustomTitle (https://core.telegram.org/bots/api#setchatadministratorcustomtitle)
|
|
//
|
|
// Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - userId (type int64): Unique identifier of the target user
|
|
// - customTitle (type string): New custom title for the administrator; 0-16 characters, emoji are not allowed
|
|
// - opts (type SetChatAdministratorCustomTitleOpts): All optional parameters.
|
|
func (bot *Bot) SetChatAdministratorCustomTitle(chatId int64, userId int64, customTitle string, opts *SetChatAdministratorCustomTitleOpts) (bool, error) {
|
|
return bot.SetChatAdministratorCustomTitleWithContext(context.Background(), chatId, userId, customTitle, opts)
|
|
}
|
|
|
|
// SetChatAdministratorCustomTitleWithContext is the same as Bot.SetChatAdministratorCustomTitle, but with a context.Context parameter
|
|
func (bot *Bot) SetChatAdministratorCustomTitleWithContext(ctx context.Context, chatId int64, userId int64, customTitle string, opts *SetChatAdministratorCustomTitleOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
v["custom_title"] = customTitle
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setChatAdministratorCustomTitle", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetChatDescriptionOpts is the set of optional fields for Bot.SetChatDescription and Bot.SetChatDescriptionWithContext.
|
|
type SetChatDescriptionOpts struct {
|
|
// New chat description, 0-255 characters
|
|
Description string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetChatDescription (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type SetChatDescriptionOpts): All optional parameters.
|
|
func (bot *Bot) SetChatDescription(chatId int64, opts *SetChatDescriptionOpts) (bool, error) {
|
|
return bot.SetChatDescriptionWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// SetChatDescriptionWithContext is the same as Bot.SetChatDescription, but with a context.Context parameter
|
|
func (bot *Bot) SetChatDescriptionWithContext(ctx context.Context, chatId int64, opts *SetChatDescriptionOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if opts != nil {
|
|
v["description"] = opts.Description
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setChatDescription", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetChatMenuButtonOpts is the set of optional fields for Bot.SetChatMenuButton and Bot.SetChatMenuButtonWithContext.
|
|
type SetChatMenuButtonOpts struct {
|
|
// Unique identifier for the target private chat. If not specified, default bot's menu button will be changed
|
|
ChatId *int64
|
|
// A JSON-serialized object for the bot's new menu button. Defaults to MenuButtonDefault
|
|
MenuButton MenuButton
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetChatMenuButton (https://core.telegram.org/bots/api#setchatmenubutton)
|
|
//
|
|
// Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.
|
|
// - opts (type SetChatMenuButtonOpts): All optional parameters.
|
|
func (bot *Bot) SetChatMenuButton(opts *SetChatMenuButtonOpts) (bool, error) {
|
|
return bot.SetChatMenuButtonWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// SetChatMenuButtonWithContext is the same as Bot.SetChatMenuButton, but with a context.Context parameter
|
|
func (bot *Bot) SetChatMenuButtonWithContext(ctx context.Context, opts *SetChatMenuButtonOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
if opts.ChatId != nil {
|
|
v["chat_id"] = strconv.FormatInt(*opts.ChatId, 10)
|
|
}
|
|
bs, err := json.Marshal(opts.MenuButton)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field menu_button: %w", err)
|
|
}
|
|
v["menu_button"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setChatMenuButton", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetChatPermissionsOpts is the set of optional fields for Bot.SetChatPermissions and Bot.SetChatPermissionsWithContext.
|
|
type SetChatPermissionsOpts struct {
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetChatPermissions (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - permissions (type ChatPermissions): A JSON-serialized object for new default chat permissions
|
|
// - opts (type SetChatPermissionsOpts): All optional parameters.
|
|
func (bot *Bot) SetChatPermissions(chatId int64, permissions ChatPermissions, opts *SetChatPermissionsOpts) (bool, error) {
|
|
return bot.SetChatPermissionsWithContext(context.Background(), chatId, permissions, opts)
|
|
}
|
|
|
|
// SetChatPermissionsWithContext is the same as Bot.SetChatPermissions, but with a context.Context parameter
|
|
func (bot *Bot) SetChatPermissionsWithContext(ctx context.Context, chatId int64, permissions ChatPermissions, opts *SetChatPermissionsOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
bs, err := json.Marshal(permissions)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field permissions: %w", err)
|
|
}
|
|
v["permissions"] = string(bs)
|
|
if opts != nil {
|
|
v["use_independent_chat_permissions"] = strconv.FormatBool(opts.UseIndependentChatPermissions)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setChatPermissions", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetChatPhotoOpts is the set of optional fields for Bot.SetChatPhoto and Bot.SetChatPhotoWithContext.
|
|
type SetChatPhotoOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetChatPhoto (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - photo (type InputFile): New chat photo, uploaded using multipart/form-data
|
|
// - opts (type SetChatPhotoOpts): All optional parameters.
|
|
func (bot *Bot) SetChatPhoto(chatId int64, photo InputFile, opts *SetChatPhotoOpts) (bool, error) {
|
|
return bot.SetChatPhotoWithContext(context.Background(), chatId, photo, opts)
|
|
}
|
|
|
|
// SetChatPhotoWithContext is the same as Bot.SetChatPhoto, but with a context.Context parameter
|
|
func (bot *Bot) SetChatPhotoWithContext(ctx context.Context, chatId int64, photo InputFile, opts *SetChatPhotoOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if photo != nil {
|
|
err := photo.Attach("photo", data)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to attach 'photo' input file: %w", err)
|
|
}
|
|
v["photo"] = photo.getValue()
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setChatPhoto", v, data, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetChatStickerSetOpts is the set of optional fields for Bot.SetChatStickerSet and Bot.SetChatStickerSetWithContext.
|
|
type SetChatStickerSetOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetChatStickerSet (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - stickerSetName (type string): Name of the sticker set to be set as the group sticker set
|
|
// - opts (type SetChatStickerSetOpts): All optional parameters.
|
|
func (bot *Bot) SetChatStickerSet(chatId int64, stickerSetName string, opts *SetChatStickerSetOpts) (bool, error) {
|
|
return bot.SetChatStickerSetWithContext(context.Background(), chatId, stickerSetName, opts)
|
|
}
|
|
|
|
// SetChatStickerSetWithContext is the same as Bot.SetChatStickerSet, but with a context.Context parameter
|
|
func (bot *Bot) SetChatStickerSetWithContext(ctx context.Context, chatId int64, stickerSetName string, opts *SetChatStickerSetOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["sticker_set_name"] = stickerSetName
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setChatStickerSet", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetChatTitleOpts is the set of optional fields for Bot.SetChatTitle and Bot.SetChatTitleWithContext.
|
|
type SetChatTitleOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetChatTitle (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - title (type string): New chat title, 1-128 characters
|
|
// - opts (type SetChatTitleOpts): All optional parameters.
|
|
func (bot *Bot) SetChatTitle(chatId int64, title string, opts *SetChatTitleOpts) (bool, error) {
|
|
return bot.SetChatTitleWithContext(context.Background(), chatId, title, opts)
|
|
}
|
|
|
|
// SetChatTitleWithContext is the same as Bot.SetChatTitle, but with a context.Context parameter
|
|
func (bot *Bot) SetChatTitleWithContext(ctx context.Context, chatId int64, title string, opts *SetChatTitleOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["title"] = title
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setChatTitle", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetCustomEmojiStickerSetThumbnailOpts is the set of optional fields for Bot.SetCustomEmojiStickerSetThumbnail and Bot.SetCustomEmojiStickerSetThumbnailWithContext.
|
|
type SetCustomEmojiStickerSetThumbnailOpts struct {
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetCustomEmojiStickerSetThumbnail (https://core.telegram.org/bots/api#setcustomemojistickersetthumbnail)
|
|
//
|
|
// Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success.
|
|
// - name (type string): Sticker set name
|
|
// - opts (type SetCustomEmojiStickerSetThumbnailOpts): All optional parameters.
|
|
func (bot *Bot) SetCustomEmojiStickerSetThumbnail(name string, opts *SetCustomEmojiStickerSetThumbnailOpts) (bool, error) {
|
|
return bot.SetCustomEmojiStickerSetThumbnailWithContext(context.Background(), name, opts)
|
|
}
|
|
|
|
// SetCustomEmojiStickerSetThumbnailWithContext is the same as Bot.SetCustomEmojiStickerSetThumbnail, but with a context.Context parameter
|
|
func (bot *Bot) SetCustomEmojiStickerSetThumbnailWithContext(ctx context.Context, name string, opts *SetCustomEmojiStickerSetThumbnailOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["name"] = name
|
|
if opts != nil {
|
|
v["custom_emoji_id"] = opts.CustomEmojiId
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setCustomEmojiStickerSetThumbnail", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetGameScoreOpts is the set of optional fields for Bot.SetGameScore and Bot.SetGameScoreWithContext.
|
|
type SetGameScoreOpts struct {
|
|
// Pass True if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters
|
|
Force bool
|
|
// Pass True if the game message should not be automatically edited to include the current scoreboard
|
|
DisableEditMessage bool
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat
|
|
ChatId int64
|
|
// Required if inline_message_id is not specified. Identifier of the sent message
|
|
MessageId int64
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message
|
|
InlineMessageId string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetGameScore (https://core.telegram.org/bots/api#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.
|
|
// - userId (type int64): User identifier
|
|
// - score (type int64): New score, must be non-negative
|
|
// - opts (type SetGameScoreOpts): All optional parameters.
|
|
func (bot *Bot) SetGameScore(userId int64, score int64, opts *SetGameScoreOpts) (*Message, bool, error) {
|
|
return bot.SetGameScoreWithContext(context.Background(), userId, score, opts)
|
|
}
|
|
|
|
// SetGameScoreWithContext is the same as Bot.SetGameScore, but with a context.Context parameter
|
|
func (bot *Bot) SetGameScoreWithContext(ctx context.Context, userId int64, score int64, opts *SetGameScoreOpts) (*Message, bool, error) {
|
|
v := map[string]string{}
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
v["score"] = strconv.FormatInt(score, 10)
|
|
if opts != nil {
|
|
v["force"] = strconv.FormatBool(opts.Force)
|
|
v["disable_edit_message"] = strconv.FormatBool(opts.DisableEditMessage)
|
|
if opts.ChatId != 0 {
|
|
v["chat_id"] = strconv.FormatInt(opts.ChatId, 10)
|
|
}
|
|
if opts.MessageId != 0 {
|
|
v["message_id"] = strconv.FormatInt(opts.MessageId, 10)
|
|
}
|
|
v["inline_message_id"] = opts.InlineMessageId
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setGameScore", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, false, err
|
|
}
|
|
|
|
var m Message
|
|
if err := json.Unmarshal(r, &m); err != nil {
|
|
var b bool
|
|
if err := json.Unmarshal(r, &b); err != nil {
|
|
return nil, false, err
|
|
}
|
|
return nil, b, nil
|
|
}
|
|
return &m, true, nil
|
|
|
|
}
|
|
|
|
// SetMessageReactionOpts is the set of optional fields for Bot.SetMessageReaction and Bot.SetMessageReactionWithContext.
|
|
type SetMessageReactionOpts struct {
|
|
// 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
|
|
// Pass True to set the reaction with a big animation
|
|
IsBig bool
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetMessageReaction (https://core.telegram.org/bots/api#setmessagereaction)
|
|
//
|
|
// Use this method to change the chosen reactions on a message. Service messages 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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - messageId (type int64): 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.
|
|
// - opts (type SetMessageReactionOpts): All optional parameters.
|
|
func (bot *Bot) SetMessageReaction(chatId int64, messageId int64, opts *SetMessageReactionOpts) (bool, error) {
|
|
return bot.SetMessageReactionWithContext(context.Background(), chatId, messageId, opts)
|
|
}
|
|
|
|
// SetMessageReactionWithContext is the same as Bot.SetMessageReaction, but with a context.Context parameter
|
|
func (bot *Bot) SetMessageReactionWithContext(ctx context.Context, chatId int64, messageId int64, opts *SetMessageReactionOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["message_id"] = strconv.FormatInt(messageId, 10)
|
|
if opts != nil {
|
|
if opts.Reaction != nil {
|
|
bs, err := json.Marshal(opts.Reaction)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field reaction: %w", err)
|
|
}
|
|
v["reaction"] = string(bs)
|
|
}
|
|
v["is_big"] = strconv.FormatBool(opts.IsBig)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setMessageReaction", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetMyCommandsOpts is the set of optional fields for Bot.SetMyCommands and Bot.SetMyCommandsWithContext.
|
|
type SetMyCommandsOpts struct {
|
|
// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
|
|
Scope BotCommandScope
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetMyCommands (https://core.telegram.org/bots/api#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.
|
|
// - commands (type []BotCommand): 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.
|
|
// - opts (type SetMyCommandsOpts): All optional parameters.
|
|
func (bot *Bot) SetMyCommands(commands []BotCommand, opts *SetMyCommandsOpts) (bool, error) {
|
|
return bot.SetMyCommandsWithContext(context.Background(), commands, opts)
|
|
}
|
|
|
|
// SetMyCommandsWithContext is the same as Bot.SetMyCommands, but with a context.Context parameter
|
|
func (bot *Bot) SetMyCommandsWithContext(ctx context.Context, commands []BotCommand, opts *SetMyCommandsOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
if commands != nil {
|
|
bs, err := json.Marshal(commands)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field commands: %w", err)
|
|
}
|
|
v["commands"] = string(bs)
|
|
}
|
|
if opts != nil {
|
|
bs, err := json.Marshal(opts.Scope)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field scope: %w", err)
|
|
}
|
|
v["scope"] = string(bs)
|
|
v["language_code"] = opts.LanguageCode
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setMyCommands", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetMyDefaultAdministratorRightsOpts is the set of optional fields for Bot.SetMyDefaultAdministratorRights and Bot.SetMyDefaultAdministratorRightsWithContext.
|
|
type SetMyDefaultAdministratorRightsOpts struct {
|
|
// A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared.
|
|
Rights *ChatAdministratorRights
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetMyDefaultAdministratorRights (https://core.telegram.org/bots/api#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.
|
|
// - opts (type SetMyDefaultAdministratorRightsOpts): All optional parameters.
|
|
func (bot *Bot) SetMyDefaultAdministratorRights(opts *SetMyDefaultAdministratorRightsOpts) (bool, error) {
|
|
return bot.SetMyDefaultAdministratorRightsWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// SetMyDefaultAdministratorRightsWithContext is the same as Bot.SetMyDefaultAdministratorRights, but with a context.Context parameter
|
|
func (bot *Bot) SetMyDefaultAdministratorRightsWithContext(ctx context.Context, opts *SetMyDefaultAdministratorRightsOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
if opts.Rights != nil {
|
|
bs, err := json.Marshal(opts.Rights)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field rights: %w", err)
|
|
}
|
|
v["rights"] = string(bs)
|
|
}
|
|
v["for_channels"] = strconv.FormatBool(opts.ForChannels)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setMyDefaultAdministratorRights", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetMyDescriptionOpts is the set of optional fields for Bot.SetMyDescription and Bot.SetMyDescriptionWithContext.
|
|
type SetMyDescriptionOpts struct {
|
|
// New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
|
|
Description string
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetMyDescription (https://core.telegram.org/bots/api#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.
|
|
// - opts (type SetMyDescriptionOpts): All optional parameters.
|
|
func (bot *Bot) SetMyDescription(opts *SetMyDescriptionOpts) (bool, error) {
|
|
return bot.SetMyDescriptionWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// SetMyDescriptionWithContext is the same as Bot.SetMyDescription, but with a context.Context parameter
|
|
func (bot *Bot) SetMyDescriptionWithContext(ctx context.Context, opts *SetMyDescriptionOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
v["description"] = opts.Description
|
|
v["language_code"] = opts.LanguageCode
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setMyDescription", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetMyNameOpts is the set of optional fields for Bot.SetMyName and Bot.SetMyNameWithContext.
|
|
type SetMyNameOpts struct {
|
|
// New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
|
|
Name string
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetMyName (https://core.telegram.org/bots/api#setmyname)
|
|
//
|
|
// Use this method to change the bot's name. Returns True on success.
|
|
// - opts (type SetMyNameOpts): All optional parameters.
|
|
func (bot *Bot) SetMyName(opts *SetMyNameOpts) (bool, error) {
|
|
return bot.SetMyNameWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// SetMyNameWithContext is the same as Bot.SetMyName, but with a context.Context parameter
|
|
func (bot *Bot) SetMyNameWithContext(ctx context.Context, opts *SetMyNameOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
v["name"] = opts.Name
|
|
v["language_code"] = opts.LanguageCode
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setMyName", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetMyShortDescriptionOpts is the set of optional fields for Bot.SetMyShortDescription and Bot.SetMyShortDescriptionWithContext.
|
|
type SetMyShortDescriptionOpts 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
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetMyShortDescription (https://core.telegram.org/bots/api#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.
|
|
// - opts (type SetMyShortDescriptionOpts): All optional parameters.
|
|
func (bot *Bot) SetMyShortDescription(opts *SetMyShortDescriptionOpts) (bool, error) {
|
|
return bot.SetMyShortDescriptionWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// SetMyShortDescriptionWithContext is the same as Bot.SetMyShortDescription, but with a context.Context parameter
|
|
func (bot *Bot) SetMyShortDescriptionWithContext(ctx context.Context, opts *SetMyShortDescriptionOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
v["short_description"] = opts.ShortDescription
|
|
v["language_code"] = opts.LanguageCode
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setMyShortDescription", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetPassportDataErrorsOpts is the set of optional fields for Bot.SetPassportDataErrors and Bot.SetPassportDataErrorsWithContext.
|
|
type SetPassportDataErrorsOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetPassportDataErrors (https://core.telegram.org/bots/api#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.
|
|
// - userId (type int64): User identifier
|
|
// - errors (type []PassportElementError): A JSON-serialized array describing the errors
|
|
// - opts (type SetPassportDataErrorsOpts): All optional parameters.
|
|
func (bot *Bot) SetPassportDataErrors(userId int64, errors []PassportElementError, opts *SetPassportDataErrorsOpts) (bool, error) {
|
|
return bot.SetPassportDataErrorsWithContext(context.Background(), userId, errors, opts)
|
|
}
|
|
|
|
// SetPassportDataErrorsWithContext is the same as Bot.SetPassportDataErrors, but with a context.Context parameter
|
|
func (bot *Bot) SetPassportDataErrorsWithContext(ctx context.Context, userId int64, errors []PassportElementError, opts *SetPassportDataErrorsOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
if errors != nil {
|
|
bs, err := json.Marshal(errors)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field errors: %w", err)
|
|
}
|
|
v["errors"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setPassportDataErrors", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetStickerEmojiListOpts is the set of optional fields for Bot.SetStickerEmojiList and Bot.SetStickerEmojiListWithContext.
|
|
type SetStickerEmojiListOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetStickerEmojiList (https://core.telegram.org/bots/api#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.
|
|
// - sticker (type string): File identifier of the sticker
|
|
// - emojiList (type []string): A JSON-serialized list of 1-20 emoji associated with the sticker
|
|
// - opts (type SetStickerEmojiListOpts): All optional parameters.
|
|
func (bot *Bot) SetStickerEmojiList(sticker string, emojiList []string, opts *SetStickerEmojiListOpts) (bool, error) {
|
|
return bot.SetStickerEmojiListWithContext(context.Background(), sticker, emojiList, opts)
|
|
}
|
|
|
|
// SetStickerEmojiListWithContext is the same as Bot.SetStickerEmojiList, but with a context.Context parameter
|
|
func (bot *Bot) SetStickerEmojiListWithContext(ctx context.Context, sticker string, emojiList []string, opts *SetStickerEmojiListOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["sticker"] = sticker
|
|
if emojiList != nil {
|
|
bs, err := json.Marshal(emojiList)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field emoji_list: %w", err)
|
|
}
|
|
v["emoji_list"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setStickerEmojiList", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetStickerKeywordsOpts is the set of optional fields for Bot.SetStickerKeywords and Bot.SetStickerKeywordsWithContext.
|
|
type SetStickerKeywordsOpts struct {
|
|
// A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters
|
|
Keywords []string
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetStickerKeywords (https://core.telegram.org/bots/api#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.
|
|
// - sticker (type string): File identifier of the sticker
|
|
// - opts (type SetStickerKeywordsOpts): All optional parameters.
|
|
func (bot *Bot) SetStickerKeywords(sticker string, opts *SetStickerKeywordsOpts) (bool, error) {
|
|
return bot.SetStickerKeywordsWithContext(context.Background(), sticker, opts)
|
|
}
|
|
|
|
// SetStickerKeywordsWithContext is the same as Bot.SetStickerKeywords, but with a context.Context parameter
|
|
func (bot *Bot) SetStickerKeywordsWithContext(ctx context.Context, sticker string, opts *SetStickerKeywordsOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["sticker"] = sticker
|
|
if opts != nil {
|
|
if opts.Keywords != nil {
|
|
bs, err := json.Marshal(opts.Keywords)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field keywords: %w", err)
|
|
}
|
|
v["keywords"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setStickerKeywords", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetStickerMaskPositionOpts is the set of optional fields for Bot.SetStickerMaskPosition and Bot.SetStickerMaskPositionWithContext.
|
|
type SetStickerMaskPositionOpts struct {
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetStickerMaskPosition (https://core.telegram.org/bots/api#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.
|
|
// - sticker (type string): File identifier of the sticker
|
|
// - opts (type SetStickerMaskPositionOpts): All optional parameters.
|
|
func (bot *Bot) SetStickerMaskPosition(sticker string, opts *SetStickerMaskPositionOpts) (bool, error) {
|
|
return bot.SetStickerMaskPositionWithContext(context.Background(), sticker, opts)
|
|
}
|
|
|
|
// SetStickerMaskPositionWithContext is the same as Bot.SetStickerMaskPosition, but with a context.Context parameter
|
|
func (bot *Bot) SetStickerMaskPositionWithContext(ctx context.Context, sticker string, opts *SetStickerMaskPositionOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["sticker"] = sticker
|
|
if opts != nil {
|
|
if opts.MaskPosition != nil {
|
|
bs, err := json.Marshal(opts.MaskPosition)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field mask_position: %w", err)
|
|
}
|
|
v["mask_position"] = string(bs)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setStickerMaskPosition", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetStickerPositionInSetOpts is the set of optional fields for Bot.SetStickerPositionInSet and Bot.SetStickerPositionInSetWithContext.
|
|
type SetStickerPositionInSetOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetStickerPositionInSet (https://core.telegram.org/bots/api#setstickerpositioninset)
|
|
//
|
|
// Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success.
|
|
// - sticker (type string): File identifier of the sticker
|
|
// - position (type int64): New sticker position in the set, zero-based
|
|
// - opts (type SetStickerPositionInSetOpts): All optional parameters.
|
|
func (bot *Bot) SetStickerPositionInSet(sticker string, position int64, opts *SetStickerPositionInSetOpts) (bool, error) {
|
|
return bot.SetStickerPositionInSetWithContext(context.Background(), sticker, position, opts)
|
|
}
|
|
|
|
// SetStickerPositionInSetWithContext is the same as Bot.SetStickerPositionInSet, but with a context.Context parameter
|
|
func (bot *Bot) SetStickerPositionInSetWithContext(ctx context.Context, sticker string, position int64, opts *SetStickerPositionInSetOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["sticker"] = sticker
|
|
v["position"] = strconv.FormatInt(position, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setStickerPositionInSet", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetStickerSetThumbnailOpts is the set of optional fields for Bot.SetStickerSetThumbnail and Bot.SetStickerSetThumbnailWithContext.
|
|
type SetStickerSetThumbnailOpts struct {
|
|
// 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: https://core.telegram.org/bots/api#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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetStickerSetThumbnail (https://core.telegram.org/bots/api#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.
|
|
// - name (type string): Sticker set name
|
|
// - userId (type int64): User identifier of the sticker set owner
|
|
// - format (type string): 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
|
|
// - opts (type SetStickerSetThumbnailOpts): All optional parameters.
|
|
func (bot *Bot) SetStickerSetThumbnail(name string, userId int64, format string, opts *SetStickerSetThumbnailOpts) (bool, error) {
|
|
return bot.SetStickerSetThumbnailWithContext(context.Background(), name, userId, format, opts)
|
|
}
|
|
|
|
// SetStickerSetThumbnailWithContext is the same as Bot.SetStickerSetThumbnail, but with a context.Context parameter
|
|
func (bot *Bot) SetStickerSetThumbnailWithContext(ctx context.Context, name string, userId int64, format string, opts *SetStickerSetThumbnailOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["name"] = name
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
v["format"] = format
|
|
if opts != nil {
|
|
if opts.Thumbnail != nil {
|
|
err := opts.Thumbnail.Attach("thumbnail", data)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to attach 'thumbnail' input file: %w", err)
|
|
}
|
|
v["thumbnail"] = opts.Thumbnail.getValue()
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setStickerSetThumbnail", v, data, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetStickerSetTitleOpts is the set of optional fields for Bot.SetStickerSetTitle and Bot.SetStickerSetTitleWithContext.
|
|
type SetStickerSetTitleOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetStickerSetTitle (https://core.telegram.org/bots/api#setstickersettitle)
|
|
//
|
|
// Use this method to set the title of a created sticker set. Returns True on success.
|
|
// - name (type string): Sticker set name
|
|
// - title (type string): Sticker set title, 1-64 characters
|
|
// - opts (type SetStickerSetTitleOpts): All optional parameters.
|
|
func (bot *Bot) SetStickerSetTitle(name string, title string, opts *SetStickerSetTitleOpts) (bool, error) {
|
|
return bot.SetStickerSetTitleWithContext(context.Background(), name, title, opts)
|
|
}
|
|
|
|
// SetStickerSetTitleWithContext is the same as Bot.SetStickerSetTitle, but with a context.Context parameter
|
|
func (bot *Bot) SetStickerSetTitleWithContext(ctx context.Context, name string, title string, opts *SetStickerSetTitleOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["name"] = name
|
|
v["title"] = title
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setStickerSetTitle", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// SetWebhookOpts is the set of optional fields for Bot.SetWebhook and Bot.SetWebhookWithContext.
|
|
type SetWebhookOpts struct {
|
|
// Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details.
|
|
Certificate InputFile
|
|
// The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS
|
|
IpAddress string
|
|
// 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
|
|
// 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 []string
|
|
// Pass True to drop all pending updates
|
|
DropPendingUpdates bool
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// SetWebhook (https://core.telegram.org/bots/api#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, we will 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.
|
|
// - url (type string): HTTPS URL to send updates to. Use an empty string to remove webhook integration
|
|
// - opts (type SetWebhookOpts): All optional parameters.
|
|
func (bot *Bot) SetWebhook(url string, opts *SetWebhookOpts) (bool, error) {
|
|
return bot.SetWebhookWithContext(context.Background(), url, opts)
|
|
}
|
|
|
|
// SetWebhookWithContext is the same as Bot.SetWebhook, but with a context.Context parameter
|
|
func (bot *Bot) SetWebhookWithContext(ctx context.Context, url string, opts *SetWebhookOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["url"] = url
|
|
if opts != nil {
|
|
if opts.Certificate != nil {
|
|
err := opts.Certificate.Attach("certificate", data)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to attach 'certificate' input file: %w", err)
|
|
}
|
|
v["certificate"] = opts.Certificate.getValue()
|
|
}
|
|
v["ip_address"] = opts.IpAddress
|
|
if opts.MaxConnections != 0 {
|
|
v["max_connections"] = strconv.FormatInt(opts.MaxConnections, 10)
|
|
}
|
|
if opts.AllowedUpdates != nil {
|
|
bs, err := json.Marshal(opts.AllowedUpdates)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to marshal field allowed_updates: %w", err)
|
|
}
|
|
v["allowed_updates"] = string(bs)
|
|
}
|
|
v["drop_pending_updates"] = strconv.FormatBool(opts.DropPendingUpdates)
|
|
v["secret_token"] = opts.SecretToken
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "setWebhook", v, data, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// StopMessageLiveLocationOpts is the set of optional fields for Bot.StopMessageLiveLocation and Bot.StopMessageLiveLocationWithContext.
|
|
type StopMessageLiveLocationOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionId string
|
|
// Required if inline_message_id is not specified. Unique identifier for the target chat
|
|
ChatId int64
|
|
// Required if inline_message_id is not specified. Identifier of the message with live location to stop
|
|
MessageId int64
|
|
// Required if chat_id and message_id are not specified. Identifier of the inline message
|
|
InlineMessageId string
|
|
// A JSON-serialized object for a new inline keyboard.
|
|
ReplyMarkup InlineKeyboardMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// StopMessageLiveLocation (https://core.telegram.org/bots/api#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.
|
|
// - opts (type StopMessageLiveLocationOpts): All optional parameters.
|
|
func (bot *Bot) StopMessageLiveLocation(opts *StopMessageLiveLocationOpts) (*Message, bool, error) {
|
|
return bot.StopMessageLiveLocationWithContext(context.Background(), opts)
|
|
}
|
|
|
|
// StopMessageLiveLocationWithContext is the same as Bot.StopMessageLiveLocation, but with a context.Context parameter
|
|
func (bot *Bot) StopMessageLiveLocationWithContext(ctx context.Context, opts *StopMessageLiveLocationOpts) (*Message, bool, error) {
|
|
v := map[string]string{}
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.ChatId != 0 {
|
|
v["chat_id"] = strconv.FormatInt(opts.ChatId, 10)
|
|
}
|
|
if opts.MessageId != 0 {
|
|
v["message_id"] = strconv.FormatInt(opts.MessageId, 10)
|
|
}
|
|
v["inline_message_id"] = opts.InlineMessageId
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, false, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "stopMessageLiveLocation", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, false, err
|
|
}
|
|
|
|
var m Message
|
|
if err := json.Unmarshal(r, &m); err != nil {
|
|
var b bool
|
|
if err := json.Unmarshal(r, &b); err != nil {
|
|
return nil, false, err
|
|
}
|
|
return nil, b, nil
|
|
}
|
|
return &m, true, nil
|
|
|
|
}
|
|
|
|
// StopPollOpts is the set of optional fields for Bot.StopPoll and Bot.StopPollWithContext.
|
|
type StopPollOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message to be edited was sent
|
|
BusinessConnectionId string
|
|
// A JSON-serialized object for a new message inline keyboard.
|
|
ReplyMarkup InlineKeyboardMarkup
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// StopPoll (https://core.telegram.org/bots/api#stoppoll)
|
|
//
|
|
// Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - messageId (type int64): Identifier of the original message with the poll
|
|
// - opts (type StopPollOpts): All optional parameters.
|
|
func (bot *Bot) StopPoll(chatId int64, messageId int64, opts *StopPollOpts) (*Poll, error) {
|
|
return bot.StopPollWithContext(context.Background(), chatId, messageId, opts)
|
|
}
|
|
|
|
// StopPollWithContext is the same as Bot.StopPoll, but with a context.Context parameter
|
|
func (bot *Bot) StopPollWithContext(ctx context.Context, chatId int64, messageId int64, opts *StopPollOpts) (*Poll, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["message_id"] = strconv.FormatInt(messageId, 10)
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
bs, err := json.Marshal(opts.ReplyMarkup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
|
|
}
|
|
v["reply_markup"] = string(bs)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "stopPoll", v, nil, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var p Poll
|
|
return &p, json.Unmarshal(r, &p)
|
|
}
|
|
|
|
// UnbanChatMemberOpts is the set of optional fields for Bot.UnbanChatMember and Bot.UnbanChatMemberWithContext.
|
|
type UnbanChatMemberOpts struct {
|
|
// Do nothing if the user is not banned
|
|
OnlyIfBanned bool
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// UnbanChatMember (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target group
|
|
// - userId (type int64): Unique identifier of the target user
|
|
// - opts (type UnbanChatMemberOpts): All optional parameters.
|
|
func (bot *Bot) UnbanChatMember(chatId int64, userId int64, opts *UnbanChatMemberOpts) (bool, error) {
|
|
return bot.UnbanChatMemberWithContext(context.Background(), chatId, userId, opts)
|
|
}
|
|
|
|
// UnbanChatMemberWithContext is the same as Bot.UnbanChatMember, but with a context.Context parameter
|
|
func (bot *Bot) UnbanChatMemberWithContext(ctx context.Context, chatId int64, userId int64, opts *UnbanChatMemberOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
if opts != nil {
|
|
v["only_if_banned"] = strconv.FormatBool(opts.OnlyIfBanned)
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "unbanChatMember", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// UnbanChatSenderChatOpts is the set of optional fields for Bot.UnbanChatSenderChat and Bot.UnbanChatSenderChatWithContext.
|
|
type UnbanChatSenderChatOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// UnbanChatSenderChat (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - senderChatId (type int64): Unique identifier of the target sender chat
|
|
// - opts (type UnbanChatSenderChatOpts): All optional parameters.
|
|
func (bot *Bot) UnbanChatSenderChat(chatId int64, senderChatId int64, opts *UnbanChatSenderChatOpts) (bool, error) {
|
|
return bot.UnbanChatSenderChatWithContext(context.Background(), chatId, senderChatId, opts)
|
|
}
|
|
|
|
// UnbanChatSenderChatWithContext is the same as Bot.UnbanChatSenderChat, but with a context.Context parameter
|
|
func (bot *Bot) UnbanChatSenderChatWithContext(ctx context.Context, chatId int64, senderChatId int64, opts *UnbanChatSenderChatOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["sender_chat_id"] = strconv.FormatInt(senderChatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "unbanChatSenderChat", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// UnhideGeneralForumTopicOpts is the set of optional fields for Bot.UnhideGeneralForumTopic and Bot.UnhideGeneralForumTopicWithContext.
|
|
type UnhideGeneralForumTopicOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// UnhideGeneralForumTopic (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type UnhideGeneralForumTopicOpts): All optional parameters.
|
|
func (bot *Bot) UnhideGeneralForumTopic(chatId int64, opts *UnhideGeneralForumTopicOpts) (bool, error) {
|
|
return bot.UnhideGeneralForumTopicWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// UnhideGeneralForumTopicWithContext is the same as Bot.UnhideGeneralForumTopic, but with a context.Context parameter
|
|
func (bot *Bot) UnhideGeneralForumTopicWithContext(ctx context.Context, chatId int64, opts *UnhideGeneralForumTopicOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "unhideGeneralForumTopic", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// UnpinAllChatMessagesOpts is the set of optional fields for Bot.UnpinAllChatMessages and Bot.UnpinAllChatMessagesWithContext.
|
|
type UnpinAllChatMessagesOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// UnpinAllChatMessages (https://core.telegram.org/bots/api#unpinallchatmessages)
|
|
//
|
|
// Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type UnpinAllChatMessagesOpts): All optional parameters.
|
|
func (bot *Bot) UnpinAllChatMessages(chatId int64, opts *UnpinAllChatMessagesOpts) (bool, error) {
|
|
return bot.UnpinAllChatMessagesWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// UnpinAllChatMessagesWithContext is the same as Bot.UnpinAllChatMessages, but with a context.Context parameter
|
|
func (bot *Bot) UnpinAllChatMessagesWithContext(ctx context.Context, chatId int64, opts *UnpinAllChatMessagesOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "unpinAllChatMessages", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// UnpinAllForumTopicMessagesOpts is the set of optional fields for Bot.UnpinAllForumTopicMessages and Bot.UnpinAllForumTopicMessagesWithContext.
|
|
type UnpinAllForumTopicMessagesOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// UnpinAllForumTopicMessages (https://core.telegram.org/bots/api#unpinallforumtopicmessages)
|
|
//
|
|
// Use this method to clear the list of pinned messages in a 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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - messageThreadId (type int64): Unique identifier for the target message thread of the forum topic
|
|
// - opts (type UnpinAllForumTopicMessagesOpts): All optional parameters.
|
|
func (bot *Bot) UnpinAllForumTopicMessages(chatId int64, messageThreadId int64, opts *UnpinAllForumTopicMessagesOpts) (bool, error) {
|
|
return bot.UnpinAllForumTopicMessagesWithContext(context.Background(), chatId, messageThreadId, opts)
|
|
}
|
|
|
|
// UnpinAllForumTopicMessagesWithContext is the same as Bot.UnpinAllForumTopicMessages, but with a context.Context parameter
|
|
func (bot *Bot) UnpinAllForumTopicMessagesWithContext(ctx context.Context, chatId int64, messageThreadId int64, opts *UnpinAllForumTopicMessagesOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
v["message_thread_id"] = strconv.FormatInt(messageThreadId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "unpinAllForumTopicMessages", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// UnpinAllGeneralForumTopicMessagesOpts is the set of optional fields for Bot.UnpinAllGeneralForumTopicMessages and Bot.UnpinAllGeneralForumTopicMessagesWithContext.
|
|
type UnpinAllGeneralForumTopicMessagesOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// UnpinAllGeneralForumTopicMessages (https://core.telegram.org/bots/api#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.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type UnpinAllGeneralForumTopicMessagesOpts): All optional parameters.
|
|
func (bot *Bot) UnpinAllGeneralForumTopicMessages(chatId int64, opts *UnpinAllGeneralForumTopicMessagesOpts) (bool, error) {
|
|
return bot.UnpinAllGeneralForumTopicMessagesWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// UnpinAllGeneralForumTopicMessagesWithContext is the same as Bot.UnpinAllGeneralForumTopicMessages, but with a context.Context parameter
|
|
func (bot *Bot) UnpinAllGeneralForumTopicMessagesWithContext(ctx context.Context, chatId int64, opts *UnpinAllGeneralForumTopicMessagesOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "unpinAllGeneralForumTopicMessages", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// UnpinChatMessageOpts is the set of optional fields for Bot.UnpinChatMessage and Bot.UnpinChatMessageWithContext.
|
|
type UnpinChatMessageOpts struct {
|
|
// Unique identifier of the business connection on behalf of which the message will be unpinned
|
|
BusinessConnectionId string
|
|
// 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
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// UnpinChatMessage (https://core.telegram.org/bots/api#unpinchatmessage)
|
|
//
|
|
// Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
|
|
// - chatId (type int64): Unique identifier for the target chat
|
|
// - opts (type UnpinChatMessageOpts): All optional parameters.
|
|
func (bot *Bot) UnpinChatMessage(chatId int64, opts *UnpinChatMessageOpts) (bool, error) {
|
|
return bot.UnpinChatMessageWithContext(context.Background(), chatId, opts)
|
|
}
|
|
|
|
// UnpinChatMessageWithContext is the same as Bot.UnpinChatMessage, but with a context.Context parameter
|
|
func (bot *Bot) UnpinChatMessageWithContext(ctx context.Context, chatId int64, opts *UnpinChatMessageOpts) (bool, error) {
|
|
v := map[string]string{}
|
|
v["chat_id"] = strconv.FormatInt(chatId, 10)
|
|
if opts != nil {
|
|
v["business_connection_id"] = opts.BusinessConnectionId
|
|
if opts.MessageId != nil {
|
|
v["message_id"] = strconv.FormatInt(*opts.MessageId, 10)
|
|
}
|
|
}
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "unpinChatMessage", v, nil, reqOpts)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
var b bool
|
|
return b, json.Unmarshal(r, &b)
|
|
}
|
|
|
|
// UploadStickerFileOpts is the set of optional fields for Bot.UploadStickerFile and Bot.UploadStickerFileWithContext.
|
|
type UploadStickerFileOpts struct {
|
|
// RequestOpts are an additional optional field to configure timeouts for individual requests
|
|
RequestOpts *RequestOpts
|
|
}
|
|
|
|
// UploadStickerFile (https://core.telegram.org/bots/api#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.
|
|
// - userId (type int64): User identifier of sticker file owner
|
|
// - sticker (type InputFile): 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: https://core.telegram.org/bots/api#sending-files
|
|
// - stickerFormat (type string): Format of the sticker, must be one of "static", "animated", "video"
|
|
// - opts (type UploadStickerFileOpts): All optional parameters.
|
|
func (bot *Bot) UploadStickerFile(userId int64, sticker InputFile, stickerFormat string, opts *UploadStickerFileOpts) (*File, error) {
|
|
return bot.UploadStickerFileWithContext(context.Background(), userId, sticker, stickerFormat, opts)
|
|
}
|
|
|
|
// UploadStickerFileWithContext is the same as Bot.UploadStickerFile, but with a context.Context parameter
|
|
func (bot *Bot) UploadStickerFileWithContext(ctx context.Context, userId int64, sticker InputFile, stickerFormat string, opts *UploadStickerFileOpts) (*File, error) {
|
|
v := map[string]string{}
|
|
data := map[string]FileReader{}
|
|
v["user_id"] = strconv.FormatInt(userId, 10)
|
|
if sticker != nil {
|
|
err := sticker.Attach("sticker", data)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to attach 'sticker' input file: %w", err)
|
|
}
|
|
v["sticker"] = sticker.getValue()
|
|
}
|
|
v["sticker_format"] = stickerFormat
|
|
|
|
var reqOpts *RequestOpts
|
|
if opts != nil {
|
|
reqOpts = opts.RequestOpts
|
|
}
|
|
|
|
r, err := bot.RequestWithContext(ctx, "uploadStickerFile", v, data, reqOpts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var f File
|
|
return &f, json.Unmarshal(r, &f)
|
|
}
|