diff --git a/CHANGELOG.md b/CHANGELOG.md index 0587878..6d79636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.11.0 (2024-11-18) + +- support API v8.0 + ## v1.10.1 (2024-11-08) - Fix arm64 panic (#130) diff --git a/README.md b/README.md index b79f43b..42a47e7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ > [Telegram Group](https://t.me/gotelegrambotui) -> Supports Bot API version: [7.11](https://core.telegram.org/bots/api#october-31-2024) from October 31, 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 diff --git a/methods.go b/methods.go index bde06d5..c4d8018 100644 --- a/methods.go +++ b/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{} @@ -811,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{} @@ -853,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 @@ -880,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/methods_params.go b/methods_params.go index f0c1ae1..2e4fc6a 100644 --- a/methods_params.go +++ b/methods_params.go @@ -396,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"` } @@ -887,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"` @@ -921,12 +938,14 @@ type SendInvoiceParams struct { } 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"` @@ -966,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"` @@ -1001,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/models/gift.go b/models/gift.go new file mode 100644 index 0000000..255465e --- /dev/null +++ b/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/models/message.go b/models/message.go index 4b7294a..8ce428e 100644 --- a/models/message.go +++ b/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/models/star.go b/models/star.go index 769eb44..6ede4ce 100644 --- a/models/star.go +++ b/models/star.go @@ -63,11 +63,13 @@ func (m *TransactionPartner) UnmarshalJSON(data []byte) error { // 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"` + 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 diff --git a/models/successful_payment.go b/models/successful_payment.go index e35573f..f6f59aa 100644 --- a/models/successful_payment.go +++ b/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