package nechotron import ( "fmt" "regexp" "strings" "github.com/NicoNex/echotron/v3" ) var chars = []string{"_", "\\*", "\\[", "\\]", "\\(", "\\)", "~", "`", ">", "#", "\\+", "\\-", "=", "|", "{", "}", "\\.", "!"} var r = strings.Join(chars, "") var reg = regexp.MustCompile("[" + r + "]+") func EscapeMd2(s string) string { return reg.ReplaceAllString(s, "\\$0") } func UserMention(u *echotron.User) string { return fmt.Sprintf("[%s](tg://user?id=%d)", EscapeMd2(u.FirstName), u.ID) }