From 5f833c8570dc21c022dcca6e33554d7a0a79fbc4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 08:38:46 +0000 Subject: [PATCH] Bump github.com/go-telegram/bot from 1.8.2 to 1.11.1 Bumps [github.com/go-telegram/bot](https://github.com/go-telegram/bot) from 1.8.2 to 1.11.1. - [Release notes](https://github.com/go-telegram/bot/releases) - [Changelog](https://github.com/go-telegram/bot/blob/main/CHANGELOG.md) - [Commits](https://github.com/go-telegram/bot/compare/v1.8.2...v1.11.1) --- updated-dependencies: - dependency-name: github.com/go-telegram/bot dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../github.com/go-telegram/bot/CHANGELOG.md | 33 ++++++++++ vendor/github.com/go-telegram/bot/README.md | 3 +- vendor/github.com/go-telegram/bot/bot.go | 9 ++- vendor/github.com/go-telegram/bot/methods.go | 42 ++++++++++++ .../go-telegram/bot/methods_params.go | 61 +++++++++++++++++- .../go-telegram/bot/models/chat_background.go | 50 ++++++++++++--- .../github.com/go-telegram/bot/models/gift.go | 15 +++++ .../go-telegram/bot/models/message.go | 6 ++ .../go-telegram/bot/models/reply_markup.go | 6 ++ .../github.com/go-telegram/bot/models/star.go | 64 ++++++++++++------- .../bot/models/successful_payment.go | 17 +++-- vendor/github.com/go-telegram/bot/options.go | 7 ++ .../go-telegram/bot/process_update.go | 13 ++-- vendor/modules.txt | 2 +- 16 files changed, 283 insertions(+), 51 deletions(-) create mode 100644 vendor/github.com/go-telegram/bot/models/gift.go diff --git a/go.mod b/go.mod index ff2f361..2440cf8 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/dustin/go-humanize v1.0.1 github.com/fogleman/gg v1.3.0 - github.com/go-telegram/bot v1.8.2 + github.com/go-telegram/bot v1.11.1 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 github.com/joho/godotenv v1.5.1 github.com/nickalie/go-webpbin v0.0.0-20220110095747-f10016bf2dc1 diff --git a/go.sum b/go.sum index 2c65242..05a2ffe 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,8 @@ github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/go-telegram/bot v1.8.2 h1:Sb2acN6FktQvSmlePDg1g+yGAWplkgFTL9eRWI6Yzy4= -github.com/go-telegram/bot v1.8.2/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM= +github.com/go-telegram/bot v1.11.1 h1:pvsXydwKpNcD1M4Y5TeKzGHUuRuQwx+FRXXgcviEFGc= +github.com/go-telegram/bot v1.11.1/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= diff --git a/vendor/github.com/go-telegram/bot/CHANGELOG.md b/vendor/github.com/go-telegram/bot/CHANGELOG.md index e56591a..12efcf7 100644 --- a/vendor/github.com/go-telegram/bot/CHANGELOG.md +++ b/vendor/github.com/go-telegram/bot/CHANGELOG.md @@ -1,5 +1,38 @@ # Changelog +## v1.11.1 (2024-11-21) + +- fix CreateNewStickerSetParams (#132) + +## v1.11.0 (2024-11-18) + +- support API v8.0 + +## v1.10.1 (2024-11-08) + +- Fix arm64 panic (#130) + +## v1.10.0 (2024-10-31) + +- support API v7.11 + +## v1.9.1 (2024-10-21) + +- fix unmarshal `ChatBackground` type (#126) + +## v1.9.0 (2024-10-17) + +- IMPORTANT! New option `WithNotAsyncHandlers` allows to run handlers in the main goroutine. Now, by default, all handlers are run in separate goroutines. + +## v1.8.4 (2024-10-10) + +- add method GetBusinessConnection (#123) + +## v1.8.3 (2024-10-07) + +- add function `bot.SetToken` +- update GitHub action versions + ## v1.8.2 (2024-09-23) - change field type `FromChatID` from string to any for `ForwardMessageParams`, `ForwardMessagesParams`, `CopyMessageParams` and `CopyMessagesParams` params diff --git a/vendor/github.com/go-telegram/bot/README.md b/vendor/github.com/go-telegram/bot/README.md index ddb79e3..42a47e7 100644 --- a/vendor/github.com/go-telegram/bot/README.md +++ b/vendor/github.com/go-telegram/bot/README.md @@ -6,7 +6,7 @@ > [Telegram Group](https://t.me/gotelegrambotui) -> Supports Bot API version: [7.10](https://core.telegram.org/bots/api#september-6-2024) from September 6, 2024 +> Supports Bot API version: [8.0](https://core.telegram.org/bots/api#november-17-2024) from November 17, 2024 It's a Go zero-dependencies telegram bot framework @@ -185,6 +185,7 @@ b, err := bot.New("YOUR_BOT_TOKEN_FROM_BOTFATHER", opts...) - `WithWebhookSecretToken(webhookSecretToken string)` - set X-Telegram-Bot-Api-Secret-Token header sent from telegram servers to confirm validity of update - `WithWorkers` - set the number of workers that are processing the Updates channel, by default 1 - `UseTestEnvironment()` - use test environment +- `WithNotAsyncHandlers()` - allows to run handlers in the main goroutine ## Message.Text and CallbackQuery.Data handlers diff --git a/vendor/github.com/go-telegram/bot/bot.go b/vendor/github.com/go-telegram/bot/bot.go index 2d37d32..7078ae2 100644 --- a/vendor/github.com/go-telegram/bot/bot.go +++ b/vendor/github.com/go-telegram/bot/bot.go @@ -31,6 +31,8 @@ type MatchFunc func(update *models.Update) bool // Bot represents Telegram Bot main object type Bot struct { + lastUpdateID int64 + url string token string pollTimeout time.Duration @@ -38,6 +40,7 @@ type Bot struct { webhookSecretToken string testEnvironment bool workers int + notAsyncHandlers bool defaultHandlerFunc HandlerFunc @@ -50,7 +53,6 @@ type Bot struct { handlers []handler client HttpClient - lastUpdateID int64 isDebug bool checkInitTimeout time.Duration @@ -98,6 +100,11 @@ func New(token string, options ...Option) (*Bot, error) { return b, nil } +// SetToken sets the bot token +func (b *Bot) SetToken(token string) { + b.token = token +} + // StartWebhook starts the Bot with webhook mode func (b *Bot) StartWebhook(ctx context.Context) { wg := sync.WaitGroup{} diff --git a/vendor/github.com/go-telegram/bot/methods.go b/vendor/github.com/go-telegram/bot/methods.go index a10eec7..c4d8018 100644 --- a/vendor/github.com/go-telegram/bot/methods.go +++ b/vendor/github.com/go-telegram/bot/methods.go @@ -216,6 +216,13 @@ func (b *Bot) GetUserProfilePhotos(ctx context.Context, params *GetUserProfilePh return result, err } +// SetUserEmojiStatus https://core.telegram.org/bots/api#setuseremojistatus +func (b *Bot) SetUserEmojiStatus(ctx context.Context, params *SetUserEmojiStatusParams) (bool, error) { + var result bool + err := b.rawRequest(ctx, "setUserEmojiStatus", params, &result) + return result, err +} + // GetFile https://core.telegram.org/bots/api#getfile func (b *Bot) GetFile(ctx context.Context, params *GetFileParams) (*models.File, error) { result := &models.File{} @@ -538,6 +545,13 @@ func (b *Bot) GetUserChatBoosts(ctx context.Context, params *GetUserChatBoostsPa return result, err } +// GetBusinessConnection https://core.telegram.org/bots/api#getbusinessconnection +func (b *Bot) GetBusinessConnection(ctx context.Context, params *GetBusinessConnectionParams) (*models.BusinessConnection, error) { + result := &models.BusinessConnection{} + err := b.rawRequest(ctx, "getBusinessConnection", params, &result) + return result, err +} + // SetMyCommands https://core.telegram.org/bots/api#setmycommands func (b *Bot) SetMyCommands(ctx context.Context, params *SetMyCommandsParams) (bool, error) { var result bool @@ -804,6 +818,13 @@ func (b *Bot) AnswerWebAppQuery(ctx context.Context, params *AnswerWebAppQueryPa return result, err } +// SavePreparedInlineMessage https://core.telegram.org/bots/api#savepreparedinlinemessage +func (b *Bot) SavePreparedInlineMessage(ctx context.Context, params *SavePreparedInlineMessageParams) (*models.PreparedInlineMessage, error) { + result := &models.PreparedInlineMessage{} + err := b.rawRequest(ctx, "savePreparedInlineMessage", params, result) + return result, err +} + // SendInvoice https://core.telegram.org/bots/api#sendinvoice func (b *Bot) SendInvoice(ctx context.Context, params *SendInvoiceParams) (*models.Message, error) { result := &models.Message{} @@ -846,6 +867,13 @@ func (b *Bot) RefundStarPayment(ctx context.Context, params *RefundStarPaymentPa return result, err } +// EditUserStarSubscription https://core.telegram.org/bots/api#edituserstarsubscription +func (b *Bot) EditUserStarSubscription(ctx context.Context, params *EditUserStarSubscriptionParams) (bool, error) { + var result bool + err := b.rawRequest(ctx, "editUserStarSubscription", params, &result) + return result, err +} + // SetPassportDataErrors https://core.telegram.org/bots/api#setpassportdataerrors func (b *Bot) SetPassportDataErrors(ctx context.Context, params *SetPassportDataErrorsParams) (bool, error) { var result bool @@ -873,3 +901,17 @@ func (b *Bot) GetGameHighScores(ctx context.Context, params *GetGameHighScoresPa err := b.rawRequest(ctx, "getGameHighScores", params, &result) return result, err } + +// GetAvailableGifts https://core.telegram.org/bots/api#getavailablegifts +func (b *Bot) GetAvailableGifts(ctx context.Context) (*models.Gifts, error) { + result := &models.Gifts{} + err := b.rawRequest(ctx, "getAvailableGifts", nil, result) + return result, err +} + +// SendGift https://core.telegram.org/bots/api#sendgift +func (b *Bot) SendGift(ctx context.Context, params *SendGiftParams) (bool, error) { + var result bool + err := b.rawRequest(ctx, "sendGift", params, &result) + return result, err +} diff --git a/vendor/github.com/go-telegram/bot/methods_params.go b/vendor/github.com/go-telegram/bot/methods_params.go index 7d6d20d..be33901 100644 --- a/vendor/github.com/go-telegram/bot/methods_params.go +++ b/vendor/github.com/go-telegram/bot/methods_params.go @@ -29,6 +29,7 @@ type SendMessageParams struct { LinkPreviewOptions *models.LinkPreviewOptions `json:"link_preview_options,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -66,6 +67,7 @@ type CopyMessageParams struct { ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -94,6 +96,7 @@ type SendPhotoParams struct { HasSpoiler bool `json:"has_spoiler,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -114,6 +117,7 @@ type SendAudioParams struct { Thumbnail models.InputFile `json:"thumbnail,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -132,6 +136,7 @@ type SendDocumentParams struct { DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -155,6 +160,7 @@ type SendVideoParams struct { SupportsStreaming bool `json:"supports_streaming,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -177,6 +183,7 @@ type SendAnimationParams struct { HasSpoiler bool `json:"has_spoiler,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -194,6 +201,7 @@ type SendVoiceParams struct { Duration int `json:"duration,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -210,6 +218,7 @@ type SendVideoNoteParams struct { Thumbnail models.InputFile `json:"thumbnail,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -228,6 +237,7 @@ type SendPaidMediaParams struct { ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -240,6 +250,7 @@ type SendMediaGroupParams struct { Media []models.InputMedia `json:"media"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` } @@ -257,6 +268,7 @@ type SendLocationParams struct { ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -299,6 +311,7 @@ type SendVenueParams struct { GooglePlaceType string `json:"google_place_type,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -315,6 +328,7 @@ type SendContactParams struct { VCard string `json:"vcard,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -341,6 +355,7 @@ type SendPollParams struct { IsClosed bool `json:"is_closed,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -354,6 +369,7 @@ type SendDiceParams struct { Emoji string `json:"emoji,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -380,6 +396,13 @@ type GetUserProfilePhotosParams struct { Limit int `json:"limit,omitempty"` } +// SetUserEmojiStatusParams https://core.telegram.org/bots/api#setuseremojistatus +type SetUserEmojiStatusParams struct { + UserID int64 `json:"user_id"` + EmojiStatusCustomEmojiID string `json:"emoji_status_custom_emoji_id,omitempty"` + EmojiStatusExpirationDate int `json:"emoji_status_expiration_date,omitempty"` +} + type GetFileParams struct { FileID string `json:"file_id"` } @@ -634,6 +657,11 @@ type GetUserChatBoostsParams struct { UserID int `json:"user_id"` } +// GetBusinessConnectionParams https://core.telegram.org/bots/api#getbusinessconnection +type GetBusinessConnectionParams struct { + BusinessConnectionID any `json:"business_connection_id"` +} + type SetMyCommandsParams struct { Commands []models.BotCommand `json:"commands"` Scope models.BotCommandScope `json:"scope,omitempty"` @@ -766,6 +794,7 @@ type SendStickerParams struct { Emoji string `json:"emoji,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -788,7 +817,7 @@ type CreateNewStickerSetParams struct { UserID int64 `json:"user_id"` Name string `json:"name"` Title string `json:"title"` - Sticker models.InputFile `json:"sticker"` + Stickers []models.Sticker `json:"stickers"` StickerType string `json:"sticker_type,omitempty"` NeedsRepainting bool `json:"needs_repainting,omitempty"` } @@ -865,6 +894,16 @@ type AnswerWebAppQueryParams struct { Result models.InlineQueryResult `json:"result"` } +// SavePreparedInlineMessageParams https://core.telegram.org/bots/api#savepreparedinlinemessage +type SavePreparedInlineMessageParams struct { + UserID int64 `json:"user_id"` + Result models.InlineQueryResult `json:"result"` + AllowUserChats bool `json:"allow_user_chats,omitempty"` + AllowBotChats bool `json:"allow_bot_chats,omitempty"` + AllowGroupChats bool `json:"allow_group_chats,omitempty"` + AllowChannelChats bool `json:"allow_channel_chats,omitempty"` +} + // SendInvoiceParams https://core.telegram.org/bots/api#sendinvoice type SendInvoiceParams struct { ChatID any `json:"chat_id"` @@ -892,18 +931,21 @@ type SendInvoiceParams struct { IsFlexible bool `json:"is_flexible,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` } type CreateInvoiceLinkParams struct { + BusinessConnectionID string `json:"business_connection_id,omitempty"` Title string `json:"title"` Description string `json:"description"` Payload string `json:"payload"` ProviderToken string `json:"provider_token,omitempty"` Currency string `json:"currency"` Prices []models.LabeledPrice `json:"prices"` + SubscriptionPeriod int `json:"subscription_period,omitempty"` MaxTipAmount int `json:"max_tip_amount,omitempty"` SuggestedTipAmounts []int `json:"suggested_tip_amounts,omitempty"` ProviderData string `json:"provider_data,omitempty"` @@ -943,6 +985,13 @@ type RefundStarPaymentParams struct { TelegramPaymentChargeID string `json:"telegram_payment_charge_id"` } +// EditUserStarSubscriptionParams https://core.telegram.org/bots/api#edituserstarsubscription +type EditUserStarSubscriptionParams struct { + UserID int64 `json:"user_id"` + TelegramPaymentChargeID string `json:"telegram_payment_charge_id"` + IsCanceled bool `json:"is_canceled"` +} + type SetPassportDataErrorsParams struct { UserID int64 `json:"user_id"` Errors []models.PassportElementError `json:"errors"` @@ -956,6 +1005,7 @@ type SendGameParams struct { GameShorName string `json:"game_short_name"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectID string `json:"message_effect_id,omitempty"` ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` @@ -977,3 +1027,12 @@ type GetGameHighScoresParams struct { MessageID int `json:"message_id,omitempty"` InlineMessageID int `json:"inline_message_id,omitempty"` } + +// SendGiftParams https://core.telegram.org/bots/api#sendgift +type SendGiftParams struct { + UserID int64 `json:"user_id"` + GiftID string `json:"gift_id"` + Text string `json:"text,omitempty"` + TextParseMode models.ParseMode `json:"text_parse_mode,omitempty"` + TextEntities []models.MessageEntity `json:"text_entities,omitempty"` +} diff --git a/vendor/github.com/go-telegram/bot/models/chat_background.go b/vendor/github.com/go-telegram/bot/models/chat_background.go index 5b082a1..996d2ef 100644 --- a/vendor/github.com/go-telegram/bot/models/chat_background.go +++ b/vendor/github.com/go-telegram/bot/models/chat_background.go @@ -26,29 +26,59 @@ type ChatBackground struct { func (cb *ChatBackground) UnmarshalJSON(data []byte) error { v := struct { - Type BackgroundType `json:"type"` + Type struct { + Type BackgroundType `json:"type"` + } `json:"type"` }{} if err := json.Unmarshal(data, &v); err != nil { return err } - switch v.Type { + switch v.Type.Type { case ChatBackgroundTypeFill: cb.Type = ChatBackgroundTypeFill - cb.Fill = &BackgroundTypeFill{} - return json.Unmarshal(data, cb.Fill) + fillContainer := &struct { + Type BackgroundTypeFill `json:"type"` + }{} + err := json.Unmarshal(data, fillContainer) + if err != nil { + return err + } + cb.Fill = &fillContainer.Type + return nil case ChatBackgroundTypeWallpaper: cb.Type = ChatBackgroundTypeWallpaper - cb.Wallpaper = &BackgroundTypeWallpaper{} - return json.Unmarshal(data, cb.Wallpaper) + wallpaperContainer := &struct { + Type BackgroundTypeWallpaper `json:"type"` + }{} + err := json.Unmarshal(data, wallpaperContainer) + if err != nil { + return err + } + cb.Wallpaper = &wallpaperContainer.Type + return nil case ChatBackgroundTypePattern: cb.Type = ChatBackgroundTypePattern - cb.Pattern = &BackgroundTypePattern{} - return json.Unmarshal(data, cb.Pattern) + patternContainer := &struct { + Type BackgroundTypePattern `json:"type"` + }{} + err := json.Unmarshal(data, patternContainer) + if err != nil { + return err + } + cb.Pattern = &patternContainer.Type + return nil case ChatBackgroundTypeChatTheme: cb.Type = ChatBackgroundTypeChatTheme - cb.Theme = &BackgroundTypeChatTheme{} - return json.Unmarshal(data, cb.Theme) + chatThemeContainer := &struct { + Type BackgroundTypeChatTheme `json:"type"` + }{} + err := json.Unmarshal(data, chatThemeContainer) + if err != nil { + return err + } + cb.Theme = &chatThemeContainer.Type + return nil } return fmt.Errorf("unsupported ChatBackground type") diff --git a/vendor/github.com/go-telegram/bot/models/gift.go b/vendor/github.com/go-telegram/bot/models/gift.go new file mode 100644 index 0000000..255465e --- /dev/null +++ b/vendor/github.com/go-telegram/bot/models/gift.go @@ -0,0 +1,15 @@ +package models + +// Gifts https://core.telegram.org/bots/api#gifts +type Gifts struct { + Gifts []Gift `json:"gifts"` +} + +// Gift https://core.telegram.org/bots/api#gift +type Gift struct { + ID string `json:"id"` + Sticker Sticker `json:"sticker"` + StarCount int `json:"star_count"` + TotalCount int `json:"total_count,omitempty"` + RemainingCount int `json:"remaining_count,omitempty"` +} diff --git a/vendor/github.com/go-telegram/bot/models/message.go b/vendor/github.com/go-telegram/bot/models/message.go index 4b7294a..8ce428e 100644 --- a/vendor/github.com/go-telegram/bot/models/message.go +++ b/vendor/github.com/go-telegram/bot/models/message.go @@ -156,3 +156,9 @@ type Message struct { WebAppData *WebAppData `json:"web_app_data,omitempty"` ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"` } + +// PreparedInlineMessage https://core.telegram.org/bots/api#preparedinlinemessage +type PreparedInlineMessage struct { + ID string `json:"id"` + ExpirationDate int `json:"expiration_date"` +} diff --git a/vendor/github.com/go-telegram/bot/models/reply_markup.go b/vendor/github.com/go-telegram/bot/models/reply_markup.go index e4d2d53..cd0d3ed 100644 --- a/vendor/github.com/go-telegram/bot/models/reply_markup.go +++ b/vendor/github.com/go-telegram/bot/models/reply_markup.go @@ -24,6 +24,11 @@ type SwitchInlineQueryChosenChat struct { AllowChannelChats bool `json:"allow_channel_chats,omitempty"` } +// CopyTextButton https://core.telegram.org/bots/api#copytextbutton +type CopyTextButton struct { + Text string `json:"text"` +} + // InlineKeyboardButton https://core.telegram.org/bots/api#inlinekeyboardbutton type InlineKeyboardButton struct { Text string `json:"text"` @@ -34,6 +39,7 @@ type InlineKeyboardButton struct { SwitchInlineQuery string `json:"switch_inline_query,omitempty"` SwitchInlineQueryCurrentChat string `json:"switch_inline_query_current_chat,omitempty"` SwitchInlineQueryChosenChat *SwitchInlineQueryChosenChat `json:"switch_inline_query_chosen_chat,omitempty"` + CopyText CopyTextButton `json:"copy_text,omitempty"` CallbackGame *CallbackGame `json:"callback_game,omitempty"` Pay bool `json:"pay,omitempty"` } diff --git a/vendor/github.com/go-telegram/bot/models/star.go b/vendor/github.com/go-telegram/bot/models/star.go index 78fb380..6ede4ce 100644 --- a/vendor/github.com/go-telegram/bot/models/star.go +++ b/vendor/github.com/go-telegram/bot/models/star.go @@ -8,18 +8,22 @@ import ( type TransactionPartnerType string const ( - TransactionPartnerTypeFragment TransactionPartnerType = "fragment" - TransactionPartnerTypeUser TransactionPartnerType = "user" - TransactionPartnerTypeOther TransactionPartnerType = "other" + TransactionPartnerTypeUser TransactionPartnerType = "user" + TransactionPartnerTypeFragment TransactionPartnerType = "fragment" + TransactionPartnerTypeTelegramAds TransactionPartnerType = "telegram_ads" + TransactionPartnerTypeTelegramApi TransactionPartnerType = "telegram_api" + TransactionPartnerTypeOther TransactionPartnerType = "other" ) // TransactionPartner https://core.telegram.org/bots/api#transactionpartner type TransactionPartner struct { Type TransactionPartnerType - Fragment *TransactionPartnerFragment `json:"fragment,omitempty"` - User *TransactionPartnerUser `json:"user,omitempty"` - Other *TransactionPartnerOther `json:"other,omitempty"` + User *TransactionPartnerUser `json:"user,omitempty"` + Fragment *TransactionPartnerFragment `json:"fragment,omitempty"` + TelegramAds *TransactionPartnerTelegramAds `json:"telegram_ads,omitempty"` + TelegramApi *TransactionPartnerTelegramApi `json:"telegram_api,omitempty"` + Other *TransactionPartnerOther `json:"other,omitempty"` } func (m *TransactionPartner) UnmarshalJSON(data []byte) error { @@ -32,14 +36,22 @@ func (m *TransactionPartner) UnmarshalJSON(data []byte) error { } switch v.Type { - case TransactionPartnerTypeFragment: - m.Type = TransactionPartnerTypeFragment - m.Fragment = &TransactionPartnerFragment{} - return json.Unmarshal(data, m.Fragment) case TransactionPartnerTypeUser: m.Type = TransactionPartnerTypeUser m.User = &TransactionPartnerUser{} return json.Unmarshal(data, m.User) + case TransactionPartnerTypeFragment: + m.Type = TransactionPartnerTypeFragment + m.Fragment = &TransactionPartnerFragment{} + return json.Unmarshal(data, m.Fragment) + case TransactionPartnerTypeTelegramAds: + m.Type = TransactionPartnerTypeTelegramAds + m.TelegramAds = &TransactionPartnerTelegramAds{} + return json.Unmarshal(data, m.TelegramAds) + case TransactionPartnerTypeTelegramApi: + m.Type = TransactionPartnerTypeTelegramApi + m.TelegramApi = &TransactionPartnerTelegramApi{} + return json.Unmarshal(data, m.TelegramApi) case TransactionPartnerTypeOther: m.Type = TransactionPartnerTypeOther m.Other = &TransactionPartnerOther{} @@ -49,19 +61,32 @@ func (m *TransactionPartner) UnmarshalJSON(data []byte) error { return fmt.Errorf("unsupported TransactionPartner type") } +// TransactionPartnerUser https://core.telegram.org/bots/api#transactionpartneruser +type TransactionPartnerUser struct { + Type TransactionPartnerType `json:"type"` + User User `json:"user"` + InvoicePayload string `json:"invoice_payload,omitempty"` + SubscriptionPeriod int `json:"subscription_period,omitempty"` + PaidMedia []*PaidMedia `json:"paid_media,omitempty"` + PaidMediaPayload string `json:"paid_media_payload,omitempty"` + Gift string `json:"gift,omitempty"` +} + // TransactionPartnerFragment https://core.telegram.org/bots/api#transactionpartnerfragment type TransactionPartnerFragment struct { Type TransactionPartnerType `json:"type"` WithdrawalState *RevenueWithdrawalState `json:"withdrawal_state,omitempty"` } -// TransactionPartnerUser https://core.telegram.org/bots/api#transactionpartneruser -type TransactionPartnerUser struct { - Type TransactionPartnerType `json:"type"` - User User `json:"user"` - InvoicePayload string `json:"invoice_payload,omitempty"` - PaidMedia []*PaidMedia `json:"paid_media,omitempty"` - PaidMediaPayload string `json:"paid_media_payload,omitempty"` +// TransactionPartnerTelegramAds https://core.telegram.org/bots/api#transactionpartnertelegramads +type TransactionPartnerTelegramAds struct { + Type TransactionPartnerType `json:"type"` +} + +// TransactionPartnerTelegramApi https://core.telegram.org/bots/api#transactionpartnertelegramapi +type TransactionPartnerTelegramApi struct { + Type TransactionPartnerType `json:"type"` + RequestCount int `json:"request_count"` } // TransactionPartnerOther https://core.telegram.org/bots/api#transactionpartnerother @@ -143,8 +168,3 @@ type StarTransaction struct { type StarTransactions struct { Transactions []StarTransaction `json:"transactions"` } - -// TransactionPartnerTelegramAds https://core.telegram.org/bots/api#transactionpartnertelegramads -type TransactionPartnerTelegramAds struct { - Type string `json:"type"` -} diff --git a/vendor/github.com/go-telegram/bot/models/successful_payment.go b/vendor/github.com/go-telegram/bot/models/successful_payment.go index e35573f..f6f59aa 100644 --- a/vendor/github.com/go-telegram/bot/models/successful_payment.go +++ b/vendor/github.com/go-telegram/bot/models/successful_payment.go @@ -2,13 +2,16 @@ package models // SuccessfulPayment https://core.telegram.org/bots/api#successfulpayment type SuccessfulPayment struct { - Currency string `json:"currency"` - TotalAmount int `json:"total_amount"` - InvoicePayload string `json:"invoice_payload"` - ShippingOptionID string `json:"shipping_option_id,omitempty"` - OrderInfo *OrderInfo `json:"order_info,omitempty"` - TelegramPaymentChargeID string `json:"telegram_payment_charge_id"` - ProviderPaymentChargeID string `json:"provider_payment_charge_id"` + Currency string `json:"currency"` + TotalAmount int `json:"total_amount"` + InvoicePayload string `json:"invoice_payload"` + SubscriptionExpirationDate int `json:"subscription_expiration_date,omitempty"` + IsRecurring bool `json:"is_recurring,omitempty"` + IsFirstRecurring bool `json:"is_first_recurring,omitempty"` + ShippingOptionID string `json:"shipping_option_id,omitempty"` + OrderInfo *OrderInfo `json:"order_info,omitempty"` + TelegramPaymentChargeID string `json:"telegram_payment_charge_id"` + ProviderPaymentChargeID string `json:"provider_payment_charge_id"` } // RefundedPayment https://core.telegram.org/bots/api#refundedpayment diff --git a/vendor/github.com/go-telegram/bot/options.go b/vendor/github.com/go-telegram/bot/options.go index 1c7a35c..8a843f3 100644 --- a/vendor/github.com/go-telegram/bot/options.go +++ b/vendor/github.com/go-telegram/bot/options.go @@ -123,3 +123,10 @@ func UseTestEnvironment() Option { b.testEnvironment = true } } + +// WithNotAsyncHandlers allows to run handlers in the main goroutine +func WithNotAsyncHandlers() Option { + return func(b *Bot) { + b.notAsyncHandlers = true + } +} diff --git a/vendor/github.com/go-telegram/bot/process_update.go b/vendor/github.com/go-telegram/bot/process_update.go index 8f54e66..88d56be 100644 --- a/vendor/github.com/go-telegram/bot/process_update.go +++ b/vendor/github.com/go-telegram/bot/process_update.go @@ -19,13 +19,16 @@ func applyMiddlewares(h HandlerFunc, m ...Middleware) HandlerFunc { // ProcessUpdate allows you to process update func (b *Bot) ProcessUpdate(ctx context.Context, upd *models.Update) { - h := b.defaultHandlerFunc + h := b.findHandler(upd) - defer func() { - applyMiddlewares(h, b.middlewares...)(ctx, b, upd) - }() + r := applyMiddlewares(h, b.middlewares...) - h = b.findHandler(upd) + if b.notAsyncHandlers { + r(ctx, b, upd) + return + } + + go r(ctx, b, upd) } func (b *Bot) findHandler(upd *models.Update) HandlerFunc { diff --git a/vendor/modules.txt b/vendor/modules.txt index a84e59e..0008d2d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -14,7 +14,7 @@ github.com/dustin/go-humanize github.com/fogleman/gg # github.com/frankban/quicktest v1.14.6 ## explicit; go 1.13 -# github.com/go-telegram/bot v1.8.2 +# github.com/go-telegram/bot v1.11.1 ## explicit; go 1.18 github.com/go-telegram/bot github.com/go-telegram/bot/models