Skip to content

Commit

Permalink
bot: fix entities passing for InputMedia
Browse files Browse the repository at this point in the history
  • Loading branch information
demget committed Nov 7, 2021
1 parent 1c91604 commit ab94471
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
14 changes: 12 additions & 2 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,12 @@ func (b *Bot) SendAlbum(to Recipient, a Album, opts ...interface{}) ([]Message,

im := x.InputMedia()
im.Media = repr
im.ParseMode = sendOpts.ParseMode

if len(sendOpts.Entities) > 0 {
im.Entities = sendOpts.Entities
} else {
im.ParseMode = sendOpts.ParseMode
}

data, _ = json.Marshal(im)
media[i] = string(data)
Expand Down Expand Up @@ -915,7 +920,12 @@ func (b *Bot) EditMedia(msg Editable, media Inputtable, opts ...interface{}) (*M

im := media.InputMedia()
im.Media = repr
im.ParseMode = sendOpts.ParseMode

if len(sendOpts.Entities) > 0 {
im.Entities = sendOpts.Entities
} else {
im.ParseMode = sendOpts.ParseMode
}

if thumb != nil {
im.Thumbnail = "attach://" + thumbName
Expand Down
9 changes: 5 additions & 4 deletions media.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ type Media interface {
// InputMedia represents a composite InputMedia struct that is
// used by Telebot in sending and editing media methods.
type InputMedia struct {
Type string `json:"type"`
Media string `json:"media"`
ParseMode string `json:"parse_mode"`
Thumbnail string `json:"thumb"`
Type string `json:"type"`
Media string `json:"media"`
Thumbnail string `json:"thumb,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
Entities Entities `json:"caption_entities,omitempty"`

*Photo
*Audio
Expand Down

0 comments on commit ab94471

Please sign in to comment.