Add options to EditCaption (incl ParseMode) (#230)

pull/241/head
Viktor Oreshkin 5 years ago
commit 10b553411d

@ -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. // EditCaption used to edit already sent photo caption with known recepient and message id.
// //
// On success, returns edited message object // 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() messageID, chatID := message.MessageSig()
params := map[string]string{"caption": caption} params := map[string]string{"caption": caption}
@ -760,6 +760,9 @@ func (b *Bot) EditCaption(message Editable, caption string) (*Message, error) {
params["message_id"] = messageID params["message_id"] = messageID
} }
sendOpts := extractOptions(options)
embedSendOptions(params, sendOpts)
respJSON, err := b.Raw("editMessageCaption", params) respJSON, err := b.Raw("editMessageCaption", params)
if err != nil { if err != nil {
return nil, err return nil, err
@ -805,6 +808,7 @@ func (b *Bot) EditMedia(message Editable, inputMedia InputMedia, options ...inte
Type string `json:"type"` Type string `json:"type"`
Caption string `json:"caption"` Caption string `json:"caption"`
Media string `json:"media"` Media string `json:"media"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
// Video. // Video.
Width int `json:"width,omitempty"` Width int `json:"width,omitempty"`
@ -828,6 +832,11 @@ func (b *Bot) EditMedia(message Editable, inputMedia InputMedia, options ...inte
resultMedia := &FileJson{Media: mediaRepr} resultMedia := &FileJson{Media: mediaRepr}
sendOpts := extractOptions(options)
if sendOpts != nil {
resultMedia.ParseMode = sendOpts.ParseMode
}
switch y := inputMedia.(type) { switch y := inputMedia.(type) {
case *Photo: case *Photo:
resultMedia.Type = "photo" resultMedia.Type = "photo"
@ -886,7 +895,6 @@ func (b *Bot) EditMedia(message Editable, inputMedia InputMedia, options ...inte
file["thumb"] = *thumb.MediaFile() file["thumb"] = *thumb.MediaFile()
} }
sendOpts := extractOptions(options)
embedSendOptions(params, sendOpts) embedSendOptions(params, sendOpts)
respJSON, err := b.sendFiles("editMessageMedia", file, params) respJSON, err := b.sendFiles("editMessageMedia", file, params)

Loading…
Cancel
Save