diff --git a/parse_mode.go b/parse_mode.go index c84bc0b..a621181 100644 --- a/parse_mode.go +++ b/parse_mode.go @@ -45,6 +45,9 @@ type ParseMode interface { // Preformated text Pre(v ...string) string + // Blockquote + Blockquote(v ...string) string + // Escape Escape(v string) string } @@ -61,13 +64,14 @@ var ( name: "HTML", separator: " ", - bold: parseModeTag{"", ""}, - italic: parseModeTag{"", ""}, - underline: parseModeTag{"", ""}, - strike: parseModeTag{"", ""}, - spoiler: parseModeTag{"", ""}, - code: parseModeTag{"", ""}, - pre: parseModeTag{"
", "
"}, + bold: parseModeTag{"", ""}, + italic: parseModeTag{"", ""}, + underline: parseModeTag{"", ""}, + strike: parseModeTag{"", ""}, + spoiler: parseModeTag{"", ""}, + code: parseModeTag{"", ""}, + pre: parseModeTag{"
", "
"}, + blockquote: parseModeTag{"
", "
"}, linkTemplate: `{title}`, @@ -95,13 +99,14 @@ var ( name: "MarkdownV2", separator: " ", - bold: parseModeTag{"*", "*"}, - italic: parseModeTag{"_", "_"}, - underline: parseModeTag{"__", "__"}, - strike: parseModeTag{"~", "~"}, - spoiler: parseModeTag{"||", "||"}, - code: parseModeTag{"`", "`"}, - pre: parseModeTag{"```", "```"}, + bold: parseModeTag{"*", "*"}, + italic: parseModeTag{"_", "_"}, + underline: parseModeTag{"__", "__"}, + strike: parseModeTag{"~", "~"}, + spoiler: parseModeTag{"||", "||"}, + code: parseModeTag{"`", "`"}, + pre: parseModeTag{"```", "```"}, + blockquote: parseModeTag{">", ""}, linkTemplate: `[{title}]({url})`, @@ -121,6 +126,7 @@ type parseMode struct { spoiler parseModeTag code parseModeTag pre parseModeTag + blockquote parseModeTag linkTemplate string escape func(string) string @@ -199,6 +205,11 @@ func (pm parseMode) Pre(v ...string) string { return pm.pre.wrap(strings.Join(v, pm.separator)) } +// Blockquote +func (pm parseMode) Blockquote(v ...string) string { + return pm.blockquote.wrap(strings.Join(v, pm.separator)) +} + func (pm parseMode) Escape(v string) string { return pm.escape(v) } diff --git a/parse_mode_test.go b/parse_mode_test.go index 059673b..2027b75 100644 --- a/parse_mode_test.go +++ b/parse_mode_test.go @@ -23,6 +23,7 @@ func TestParseModeHTML(t *testing.T) { assert.Equal(t, "Hello World", HTML.Code("Hello World")) assert.Equal(t, "
Hello World
", HTML.Pre("Hello World")) assert.Equal(t, "Hello, World", HTML.Sep(", ").Bold("Hello", "World")) + assert.Equal(t, "
Hello, World
", HTML.Sep(", ").Blockquote("Hello", "World")) assert.Equal(t, "Me & You", HTML.Escape("Me & You")) } @@ -55,6 +56,7 @@ func TestParseModeMarkdownV2(t *testing.T) { assert.Equal(t, "[Hello World](https://telegram.org)", MD2.Link("Hello World", "https://telegram.org")) assert.Equal(t, "`Hello World`", MD2.Code("Hello World")) assert.Equal(t, "```Hello World```", MD2.Pre("Hello World")) + assert.Equal(t, ">Hello World", MD2.Blockquote("Hello World")) assert.Equal(t, "*Hello, World*", MD2.Sep(", ").Bold("Hello", "World")) assert.Equal(t, "\\[\\*go\\_tg\\*\\]", MD2.Escape("[*go_tg*]"))