mirror of
https://github.com/tucnak/telebot
synced 2024-11-03 09:40:18 +00:00
Add options to EditCaption (incl ParseMode) (#230)
This commit is contained in:
commit
10b553411d
18
bot.go
18
bot.go
@ -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}
|
||||
@ -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
|
||||
@ -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"`
|
||||
@ -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"
|
||||
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user