Merge pull request #189 from mr-linch/full-parse-mode-support

Parse mode in captions
bot-api-6.1
Syfaro 2018-08-27 15:39:08 -05:00 committed by GitHub
commit b0bdb27e05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 45 additions and 12 deletions

View File

@ -253,9 +253,9 @@ func (config PhotoConfig) params() (map[string]string, error) {
if config.Caption != "" { if config.Caption != "" {
params["caption"] = config.Caption params["caption"] = config.Caption
} if config.ParseMode != "" {
if config.ParseMode != "" { params["parse_mode"] = config.ParseMode
params["parse_mode"] = config.ParseMode }
} }
return params, nil return params, nil
@ -271,10 +271,11 @@ func (config PhotoConfig) values() (url.Values, error) {
v.Add(config.name(), config.FileID) v.Add(config.name(), config.FileID)
if config.Caption != "" { if config.Caption != "" {
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode)
}
} }
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode)
}
return v, nil return v, nil
} }
@ -292,6 +293,7 @@ func (config PhotoConfig) method() string {
type AudioConfig struct { type AudioConfig struct {
BaseFile BaseFile
Caption string Caption string
ParseMode string
Duration int Duration int
Performer string Performer string
Title string Title string
@ -317,6 +319,9 @@ func (config AudioConfig) values() (url.Values, error) {
} }
if config.Caption != "" { if config.Caption != "" {
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode)
}
} }
return v, nil return v, nil
@ -338,6 +343,9 @@ func (config AudioConfig) params() (map[string]string, error) {
} }
if config.Caption != "" { if config.Caption != "" {
params["caption"] = config.Caption params["caption"] = config.Caption
if config.ParseMode != "" {
params["parse_mode"] = config.ParseMode
}
} }
return params, nil return params, nil
@ -356,7 +364,8 @@ func (config AudioConfig) method() string {
// DocumentConfig contains information about a SendDocument request. // DocumentConfig contains information about a SendDocument request.
type DocumentConfig struct { type DocumentConfig struct {
BaseFile BaseFile
Caption string Caption string
ParseMode string
} }
// values returns a url.Values representation of DocumentConfig. // values returns a url.Values representation of DocumentConfig.
@ -369,6 +378,9 @@ func (config DocumentConfig) values() (url.Values, error) {
v.Add(config.name(), config.FileID) v.Add(config.name(), config.FileID)
if config.Caption != "" { if config.Caption != "" {
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode)
}
} }
return v, nil return v, nil
@ -380,6 +392,9 @@ func (config DocumentConfig) params() (map[string]string, error) {
if config.Caption != "" { if config.Caption != "" {
params["caption"] = config.Caption params["caption"] = config.Caption
if config.ParseMode != "" {
params["parse_mode"] = config.ParseMode
}
} }
return params, nil return params, nil
@ -432,8 +447,9 @@ func (config StickerConfig) method() string {
// VideoConfig contains information about a SendVideo request. // VideoConfig contains information about a SendVideo request.
type VideoConfig struct { type VideoConfig struct {
BaseFile BaseFile
Duration int Duration int
Caption string Caption string
ParseMode string
} }
// values returns a url.Values representation of VideoConfig. // values returns a url.Values representation of VideoConfig.
@ -449,6 +465,9 @@ func (config VideoConfig) values() (url.Values, error) {
} }
if config.Caption != "" { if config.Caption != "" {
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode)
}
} }
return v, nil return v, nil
@ -460,6 +479,9 @@ func (config VideoConfig) params() (map[string]string, error) {
if config.Caption != "" { if config.Caption != "" {
params["caption"] = config.Caption params["caption"] = config.Caption
if config.ParseMode != "" {
params["parse_mode"] = config.ParseMode
}
} }
return params, nil return params, nil
@ -529,8 +551,9 @@ func (config VideoNoteConfig) method() string {
// VoiceConfig contains information about a SendVoice request. // VoiceConfig contains information about a SendVoice request.
type VoiceConfig struct { type VoiceConfig struct {
BaseFile BaseFile
Caption string Caption string
Duration int ParseMode string
Duration int
} }
// values returns a url.Values representation of VoiceConfig. // values returns a url.Values representation of VoiceConfig.
@ -546,6 +569,9 @@ func (config VoiceConfig) values() (url.Values, error) {
} }
if config.Caption != "" { if config.Caption != "" {
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode)
}
} }
return v, nil return v, nil
@ -560,6 +586,9 @@ func (config VoiceConfig) params() (map[string]string, error) {
} }
if config.Caption != "" { if config.Caption != "" {
params["caption"] = config.Caption params["caption"] = config.Caption
if config.ParseMode != "" {
params["parse_mode"] = config.ParseMode
}
} }
return params, nil return params, nil
@ -793,13 +822,17 @@ func (config EditMessageTextConfig) method() string {
// EditMessageCaptionConfig allows you to modify the caption of a message. // EditMessageCaptionConfig allows you to modify the caption of a message.
type EditMessageCaptionConfig struct { type EditMessageCaptionConfig struct {
BaseEdit BaseEdit
Caption string Caption string
ParseMode string
} }
func (config EditMessageCaptionConfig) values() (url.Values, error) { func (config EditMessageCaptionConfig) values() (url.Values, error) {
v, _ := config.BaseEdit.values() v, _ := config.BaseEdit.values()
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode)
}
return v, nil return v, nil
} }