Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7.9 #103

Merged
merged 2 commits into from
Aug 14, 2024
Merged

7.9 #103

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
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.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

Expand Down
14 changes: 14 additions & 0 deletions methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
14 changes: 14 additions & 0 deletions methods_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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"`
Expand Down
5 changes: 3 additions & 2 deletions models/chat_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions models/reaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,6 +20,7 @@ type ReactionType struct {

ReactionTypeEmoji *ReactionTypeEmoji
ReactionTypeCustomEmoji *ReactionTypeCustomEmoji
ReactionTypePaid *ReactionTypePaid
}

func (rt *ReactionType) MarshalJSON() ([]byte, error) {
Expand Down Expand Up @@ -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")
Expand All @@ -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"`
Expand Down
18 changes: 18 additions & 0 deletions models/reaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
1 change: 1 addition & 0 deletions models/star.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading