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

Bot API 7.6 #711

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 2 additions & 1 deletion chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type Chat struct {
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
CustomEmojiSetName string `json:"custom_emoji_sticker_set_name"`
LinkedChatID int64 `json:"linked_chat_id,omitempty"`
ChatLocation *ChatLocation `json:"location,omitempty"`
Location *ChatLocation `json:"location,omitempty"`
Private bool `json:"has_private_forwards,omitempty"`
Protected bool `json:"has_protected_content,omitempty"`
NoVoiceAndVideo bool `json:"has_restricted_voice_and_video_messages"`
Expand All @@ -80,6 +80,7 @@ type Chat struct {
BusinessIntro BusinessIntro `json:"business_intro,omitempty"`
BusinessLocation BusinessLocation `json:"business_location,omitempty"`
BusinessOpeningHours BusinessOpeningHours `json:"business_opening_hours,omitempty"`
CanSendPaidMedia bool `json:"can_send_paid_media"`
}

// Recipient returns chat ID (see Recipient interface).
Expand Down
7 changes: 7 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ type Context interface {

// Set saves data in the context.
Set(key string, val interface{})

// Payment returns payment instance.
Payment() *Payment
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it to other functions that return update/message types

}

// nativeContext is a native implementation of the Context interface.
Expand Down Expand Up @@ -538,3 +541,7 @@ func (c *nativeContext) Get(key string) interface{} {
defer c.lock.RUnlock()
return c.store[key]
}

func (c *nativeContext) Payment() *Payment {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well. Keep file ordered and easy to navigate.

return c.u.Message.Payment
}
24 changes: 24 additions & 0 deletions media.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ type InputMedia struct {
HasSpoiler bool `json:"has_spoiler,omitempty"`
}

type InputPaidMedia struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InputMedia has the same set of fields, so we can avoid creating another structure

Type string `json:"type"`
Media string `json:"media"`
Thumbnail string `json:"thumbnail,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Duration int `json:"duration,omitempty"`
SupportsStreaming bool `json:"supports_streaming"`
}

type PaidMediaInfo struct {
StarCount int `json:"star_count"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
StarCount int `json:"star_count"`
Stars int `json:"star_count"`

PaidMedia []PaidMedia `json:"paid_media"`
}

type PaidMedia struct {
Type string `json:"type"`
Photo []photoSize `json:"photo,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Photo []photoSize `json:"photo,omitempty"`
Photo *Photo `json:"photo,omitempty"`

Video Video `json:"video,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Duration int `json:"duration,omitempty"`
}

// Inputtable is a generic type for all kinds of media you
// can put into an album.
type Inputtable interface {
Expand Down
6 changes: 6 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ type Message struct {
// For a general file, information about it.
Document *Document `json:"document"`

// Message contains paid media; information about the paid media
PaidMedia PaidMediaInfo `json:"paid_media"`

// For a photo, all available sizes (thumbnails).
Photo *Photo `json:"photo"`

Expand Down Expand Up @@ -663,6 +666,9 @@ type ExternalReplyInfo struct {
// (Optional) Message is a general file, information about the file.
Document *Document `json:"document"`

// Message contains paid media; information about the paid media
PaidMedia PaidMediaInfo `json:"paid_media"`

// (Optional) Message is a photo, available sizes of the photo.
Photo []Photo `json:"photo"`

Expand Down
Loading