Skip to content

Instantly share code, notes, and snippets.

@shuiRong
Created April 12, 2021 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuiRong/02e928cdfbe563dc3df18421c0b60ead to your computer and use it in GitHub Desktop.
Save shuiRong/02e928cdfbe563dc3df18421c0b60ead to your computer and use it in GitHub Desktop.
telegram escape string | markdownv2
package main
import (
"fmt"
"strings"
)
func main() {
var htmlEscaper = strings.NewReplacer(
"#", "\\#",
"-", "\\-",
"*", "\\*",
"[", "\\[",
"]", "\\]",
"(", "\\(",
")", "\\)",
"~", "\\~",
"`", "\\`",
">", "\\>",
"+", "\\+",
"-", "\\-",
"=", "\\=",
"|", "\\|",
"{", "\\{",
"}", "\\}",
".", "\\.",
"!", "\\!",
)
fmt.Println(htmlEscaper.Replace("科兴灭活病毒COVID-19疫苗在巴西的3期临床试验PROFISCOV研究数据:间隔14天打第二针有效率50.7%,预防中症率83.7%,防护重症率100%"))
}
// doc: https://core.telegram.org/bots/api#formatting-options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment