Skip to content

Commit

Permalink
API v8.0 (#133)
Browse files Browse the repository at this point in the history
* bot api 8.0

* readme
  • Loading branch information
negasus authored Nov 18, 2024
1 parent 8acf38b commit a12a771
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
35 changes: 35 additions & 0 deletions methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
35 changes: 35 additions & 0 deletions methods_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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"`
}
15 changes: 15 additions & 0 deletions models/gift.go
Original file line number Diff line number Diff line change
@@ -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"`
}
6 changes: 6 additions & 0 deletions models/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
12 changes: 7 additions & 5 deletions models/star.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions models/successful_payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a12a771

Please sign in to comment.