all repos — telegram-bot-api @ b0bdb27e0512094145fd6a38387985bb8394f327

Golang bindings for the Telegram Bot API

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

Parse mode in captions
Syfaro syfaro@huefox.com
Mon, 27 Aug 2018 15:39:08 -0500
commit

b0bdb27e0512094145fd6a38387985bb8394f327

parent

e21c8668476e99fea8312247293cae14444af05a

1 files changed, 45 insertions(+), 12 deletions(-)

jump to
M configs.goconfigs.go

@@ -253,9 +253,9 @@ params, _ := config.BaseFile.params()

if config.Caption != "" { params["caption"] = config.Caption - } - if config.ParseMode != "" { - params["parse_mode"] = config.ParseMode + if config.ParseMode != "" { + params["parse_mode"] = config.ParseMode + } } return params, nil

@@ -271,10 +271,11 @@

v.Add(config.name(), config.FileID) if 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 }

@@ -292,6 +293,7 @@ // AudioConfig contains information about a SendAudio request.

type AudioConfig struct { BaseFile Caption string + ParseMode string Duration int Performer string Title string

@@ -317,6 +319,9 @@ v.Add("title", config.Title)

} if config.Caption != "" { v.Add("caption", config.Caption) + if config.ParseMode != "" { + v.Add("parse_mode", config.ParseMode) + } } return v, nil

@@ -338,6 +343,9 @@ params["title"] = config.Title

} if config.Caption != "" { params["caption"] = config.Caption + if config.ParseMode != "" { + params["parse_mode"] = config.ParseMode + } } return params, nil

@@ -356,7 +364,8 @@

// DocumentConfig contains information about a SendDocument request. type DocumentConfig struct { BaseFile - Caption string + Caption string + ParseMode string } // values returns a url.Values representation of DocumentConfig.

@@ -369,6 +378,9 @@

v.Add(config.name(), config.FileID) if config.Caption != "" { v.Add("caption", config.Caption) + if config.ParseMode != "" { + v.Add("parse_mode", config.ParseMode) + } } return v, nil

@@ -380,6 +392,9 @@ params, _ := config.BaseFile.params()

if config.Caption != "" { params["caption"] = config.Caption + if config.ParseMode != "" { + params["parse_mode"] = config.ParseMode + } } return params, nil

@@ -432,8 +447,9 @@

// VideoConfig contains information about a SendVideo request. type VideoConfig struct { BaseFile - Duration int - Caption string + Duration int + Caption string + ParseMode string } // values returns a url.Values representation of VideoConfig.

@@ -449,6 +465,9 @@ v.Add("duration", strconv.Itoa(config.Duration))

} if config.Caption != "" { v.Add("caption", config.Caption) + if config.ParseMode != "" { + v.Add("parse_mode", config.ParseMode) + } } return v, nil

@@ -460,6 +479,9 @@ params, _ := config.BaseFile.params()

if config.Caption != "" { params["caption"] = config.Caption + if config.ParseMode != "" { + params["parse_mode"] = config.ParseMode + } } return params, nil

@@ -529,8 +551,9 @@

// VoiceConfig contains information about a SendVoice request. type VoiceConfig struct { BaseFile - Caption string - Duration int + Caption string + ParseMode string + Duration int } // values returns a url.Values representation of VoiceConfig.

@@ -546,6 +569,9 @@ v.Add("duration", strconv.Itoa(config.Duration))

} if config.Caption != "" { v.Add("caption", config.Caption) + if config.ParseMode != "" { + v.Add("parse_mode", config.ParseMode) + } } return v, nil

@@ -560,6 +586,9 @@ params["duration"] = strconv.Itoa(config.Duration)

} if config.Caption != "" { params["caption"] = config.Caption + if config.ParseMode != "" { + params["parse_mode"] = config.ParseMode + } } return params, nil

@@ -793,13 +822,17 @@

// EditMessageCaptionConfig allows you to modify the caption of a message. type EditMessageCaptionConfig struct { BaseEdit - Caption string + Caption string + ParseMode string } func (config EditMessageCaptionConfig) values() (url.Values, error) { v, _ := config.BaseEdit.values() v.Add("caption", config.Caption) + if config.ParseMode != "" { + v.Add("parse_mode", config.ParseMode) + } return v, nil }