From d3c9da3df278d99cac0db4bb34dddbcf9be342e7 Mon Sep 17 00:00:00 2001 From: negasus Date: Wed, 14 Aug 2024 16:42:20 +0300 Subject: [PATCH 1/2] api 7.9 --- methods.go | 14 ++++++++++++++ methods_params.go | 14 ++++++++++++++ models/chat_member.go | 5 +++-- models/reaction.go | 11 +++++++++++ models/reaction_test.go | 18 ++++++++++++++++++ models/star.go | 1 + 6 files changed, 61 insertions(+), 2 deletions(-) diff --git a/methods.go b/methods.go index 55277b3..a10eec7 100644 --- a/methods.go +++ b/methods.go @@ -300,6 +300,20 @@ func (b *Bot) EditChatInviteLink(ctx context.Context, params *EditChatInviteLink return result, err } +// CreateChatSubscriptionInviteLink https://core.telegram.org/bots/api#createchatsubscriptioninvitelink +func (b *Bot) CreateChatSubscriptionInviteLink(ctx context.Context, params *CreateChatSubscriptionInviteLinkParams) (*models.ChatInviteLink, error) { + result := &models.ChatInviteLink{} + err := b.rawRequest(ctx, "createChatSubscriptionInviteLink", params, &result) + return result, err +} + +// EditChatSubscriptionInviteLink https://core.telegram.org/bots/api#editchatsubscriptioninvitelink +func (b *Bot) EditChatSubscriptionInviteLink(ctx context.Context, params *EditChatSubscriptionInviteLinkParams) (*models.ChatInviteLink, error) { + result := &models.ChatInviteLink{} + err := b.rawRequest(ctx, "editChatSubscriptionInviteLink", params, &result) + return result, err +} + // RevokeChatInviteLink https://core.telegram.org/bots/api#revokechatinvitelink func (b *Bot) RevokeChatInviteLink(ctx context.Context, params *RevokeChatInviteLinkParams) (*models.ChatInviteLink, error) { result := &models.ChatInviteLink{} diff --git a/methods_params.go b/methods_params.go index d160495..4e15aa8 100644 --- a/methods_params.go +++ b/methods_params.go @@ -217,6 +217,7 @@ type SendVideoNoteParams struct { // SendPaidMediaParams https://core.telegram.org/bots/api#sendpaidmedia type SendPaidMediaParams struct { + BusinessConnectionID string `json:"business_connection_id,omitempty"` ChatID any `json:"chat_id"` StarCount int `json:"star_count"` Media []models.InputPaidMedia `json:"media"` @@ -466,6 +467,19 @@ type EditChatInviteLinkParams struct { CreatesJoinRequest bool `json:"creates_join_request,omitempty"` } +type CreateChatSubscriptionInviteLinkParams struct { + ChatID any `json:"chat_id"` + Name string `json:"name,omitempty"` + SubscriptionPeriod int `json:"subscription_period"` + SubscriptionPrice int `json:"subscription_price"` +} + +type EditChatSubscriptionInviteLinkParams struct { + ChatID any `json:"chat_id"` + InviteLink string `json:"invite_link"` + Name string `json:"name,omitempty"` +} + type RevokeChatInviteLinkParams struct { ChatID any `json:"chat_id"` InviteLink string `json:"invite_link"` diff --git a/models/chat_member.go b/models/chat_member.go index e3cb60a..1721ae0 100644 --- a/models/chat_member.go +++ b/models/chat_member.go @@ -136,8 +136,9 @@ type ChatMemberAdministrator struct { // ChatMemberMember https://core.telegram.org/bots/api#chatmembermember type ChatMemberMember struct { - Status ChatMemberType `json:"status"` // The member's status in the chat, always “member” - User *User `json:"user"` + Status ChatMemberType `json:"status"` // The member's status in the chat, always “member” + User *User `json:"user"` + UntilDate int `json:"until_date,omitempty"` } // ChatMemberRestricted https://core.telegram.org/bots/api#chatmemberrestricted diff --git a/models/reaction.go b/models/reaction.go index f0973a6..b7d0d6b 100644 --- a/models/reaction.go +++ b/models/reaction.go @@ -11,6 +11,7 @@ type ReactionTypeType string const ( ReactionTypeTypeEmoji ReactionTypeType = "emoji" ReactionTypeTypeCustomEmoji ReactionTypeType = "custom_emoji" + ReactionTypeTypePaid ReactionTypeType = "paid" ) // ReactionType https://core.telegram.org/bots/api#reactiontype @@ -19,6 +20,7 @@ type ReactionType struct { ReactionTypeEmoji *ReactionTypeEmoji ReactionTypeCustomEmoji *ReactionTypeCustomEmoji + ReactionTypePaid *ReactionTypePaid } func (rt *ReactionType) MarshalJSON() ([]byte, error) { @@ -52,6 +54,10 @@ func (rt *ReactionType) UnmarshalJSON(data []byte) error { rt.Type = ReactionTypeTypeCustomEmoji rt.ReactionTypeCustomEmoji = &ReactionTypeCustomEmoji{} return json.Unmarshal(data, rt.ReactionTypeCustomEmoji) + case "paid": + rt.Type = ReactionTypeTypePaid + rt.ReactionTypePaid = &ReactionTypePaid{} + return json.Unmarshal(data, rt.ReactionTypePaid) } return fmt.Errorf("unsupported ReactionType type") @@ -69,6 +75,11 @@ type ReactionTypeCustomEmoji struct { CustomEmojiID string `json:"custom_emoji_id"` } +// ReactionTypePaid https://core.telegram.org/bots/api#reactiontypepaid +type ReactionTypePaid struct { + Type string `json:"type"` +} + // MessageReactionUpdated https://core.telegram.org/bots/api#messagereactionupdated type MessageReactionUpdated struct { Chat Chat `json:"chat"` diff --git a/models/reaction_test.go b/models/reaction_test.go index af0de88..fe1fbcd 100644 --- a/models/reaction_test.go +++ b/models/reaction_test.go @@ -45,3 +45,21 @@ func TestUnmarshalReactionType_custom_emoji(t *testing.T) { t.Fatal("wrong custom emoji id") } } + +func TestUnmarshalReactionType_paid(t *testing.T) { + src := `{"type":"paid"}` + + var rt ReactionType + err := rt.UnmarshalJSON([]byte(src)) + if err != nil { + t.Fatal(err) + } + + if rt.Type != ReactionTypeTypePaid { + t.Fatal("wrong type") + } + + if rt.ReactionTypePaid == nil { + t.Fatal("ReactionTypePaid is nil") + } +} diff --git a/models/star.go b/models/star.go index 721eac0..76b9406 100644 --- a/models/star.go +++ b/models/star.go @@ -60,6 +60,7 @@ type TransactionPartnerUser struct { Type TransactionPartnerType `json:"type"` User User `json:"user"` InvoicePayload string `json:"invoice_payload,omitempty"` + PaidMedia []*PaidMedia `json:"paid_media,omitempty"` } // TransactionPartnerOther https://core.telegram.org/bots/api#transactionpartnerother From ee79ec5ee2a88720ca28d6b436ceea41d31d7e61 Mon Sep 17 00:00:00 2001 From: negasus Date: Wed, 14 Aug 2024 16:43:15 +0300 Subject: [PATCH 2/2] changelog, readme --- CHANGELOG.md | 4 ++++ README.md | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b782c..b6adebe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.7.0 (2024-08-14) + +- support API v7.9 + ## v1.6.1 (2024-07-25) - add ValidateWebappRequest func for validate MiniApp requests diff --git a/README.md b/README.md index 4aa6dd0..1055b52 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ > [Telegram Group](https://t.me/gotelegrambotui) -> Supports Bot API version: [7.7](https://core.telegram.org/bots/api#july-7-2024) from July 7, 2024 +> Supports Bot API version: [7.9](https://core.telegram.org/bots/api#august-14-2024) from August 14, 2024 It's a Go zero-dependencies telegram bot framework