From ab11be604a835a29e69a781ddba659d2bc2e2937 Mon Sep 17 00:00:00 2001 From: Ronmi Ren Date: Mon, 14 Sep 2015 11:15:16 +0800 Subject: [PATCH 1/2] Support new API: markdown message. --- api.go | 4 ++++ options.go | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/api.go b/api.go index f93fdbe..9b87ebe 100644 --- a/api.go +++ b/api.go @@ -95,6 +95,10 @@ func embedSendOptions(params *url.Values, options *SendOptions) { params.Set("disable_web_page_preview", "true") } + if options.ParseMode != ModeDefault { + params.Set("parse_mode", string(options.ParseMode)) + } + // process reply_markup if options.ReplyMarkup.ForceReply || options.ReplyMarkup.CustomKeyboard != nil || options.ReplyMarkup.HideCustomKeyboard { replyMarkup, _ := json.Marshal(options.ReplyMarkup) diff --git a/options.go b/options.go index 1cb82b7..764b743 100644 --- a/options.go +++ b/options.go @@ -1,5 +1,14 @@ package telebot +// ParseMode is new bot api released at Sep 7, 2015. It adds markdown support to sendMessage API +type ParseMode string + +// Supported ParseMode +const ( + ModeDefault ParseMode = "" + ModeMarkdown ParseMode = "Markdown" +) + // SendOptions represents a set of custom options that could // be appled to messages sent. type SendOptions struct { @@ -11,6 +20,9 @@ type SendOptions struct { // For text messages, disables previews for links in this message. DisableWebPagePreview bool + + // ParseMode controls how client apps render your message. + ParseMode ParseMode } type ReplyMarkup struct { From 32d0662cde8518785bfa479680e3b72119211c06 Mon Sep 17 00:00:00 2001 From: Ronmi Ren Date: Tue, 15 Sep 2015 20:24:34 +0800 Subject: [PATCH 2/2] update documentation --- options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options.go b/options.go index 764b743..915275e 100644 --- a/options.go +++ b/options.go @@ -1,6 +1,6 @@ package telebot -// ParseMode is new bot api released at Sep 7, 2015. It adds markdown support to sendMessage API +// ParseMode determines the way client applications treat the text of the message type ParseMode string // Supported ParseMode