Skip to content

Commit

Permalink
Add options to EditCaption (incl ParseMode) (tucnak#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
stek29 committed Dec 25, 2019
2 parents ca2149b + a855bcb commit 10b5534
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ func (b *Bot) EditReplyMarkup(message Editable, markup *ReplyMarkup) (*Message,
// EditCaption used to edit already sent photo caption with known recepient and message id.
//
// On success, returns edited message object
func (b *Bot) EditCaption(message Editable, caption string) (*Message, error) {
func (b *Bot) EditCaption(message Editable, caption string, options ...interface{}) (*Message, error) {
messageID, chatID := message.MessageSig()

params := map[string]string{"caption": caption}
Expand All @@ -760,6 +760,9 @@ func (b *Bot) EditCaption(message Editable, caption string) (*Message, error) {
params["message_id"] = messageID
}

sendOpts := extractOptions(options)
embedSendOptions(params, sendOpts)

respJSON, err := b.Raw("editMessageCaption", params)
if err != nil {
return nil, err
Expand Down Expand Up @@ -802,9 +805,10 @@ func (b *Bot) EditMedia(message Editable, inputMedia InputMedia, options ...inte

type FileJson struct {
// All types.
Type string `json:"type"`
Caption string `json:"caption"`
Media string `json:"media"`
Type string `json:"type"`
Caption string `json:"caption"`
Media string `json:"media"`
ParseMode ParseMode `json:"parse_mode,omitempty"`

// Video.
Width int `json:"width,omitempty"`
Expand All @@ -828,6 +832,11 @@ func (b *Bot) EditMedia(message Editable, inputMedia InputMedia, options ...inte

resultMedia := &FileJson{Media: mediaRepr}

sendOpts := extractOptions(options)
if sendOpts != nil {
resultMedia.ParseMode = sendOpts.ParseMode
}

switch y := inputMedia.(type) {
case *Photo:
resultMedia.Type = "photo"
Expand Down Expand Up @@ -886,7 +895,6 @@ func (b *Bot) EditMedia(message Editable, inputMedia InputMedia, options ...inte
file["thumb"] = *thumb.MediaFile()
}

sendOpts := extractOptions(options)
embedSendOptions(params, sendOpts)

respJSON, err := b.sendFiles("editMessageMedia", file, params)
Expand Down

0 comments on commit 10b5534

Please sign in to comment.