Skip to content

Commit

Permalink
add a helper method to escape MarkdownV2 Telegram messages
Browse files Browse the repository at this point in the history
  • Loading branch information
penguinpowernz committed Dec 26, 2021
1 parent 6f8dc23 commit 7c76010
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import (
func isTicker(s string) bool {
return strings.HasPrefix(s, "$")
}

func tgEscape(s string) string {
s = strings.ReplaceAll(s, ".", `\.`)
s = strings.ReplaceAll(s, "(", `\(`)
s = strings.ReplaceAll(s, ")", `\)`)
s = strings.ReplaceAll(s, "-", `\-`)
s = strings.ReplaceAll(s, "$", `\$`)
s = strings.ReplaceAll(s, ":", `\:`)
return s
}

func normalizeDate(ts string) time.Time {
t, _ := time.Parse("2006-01-02", ts)

Expand Down

0 comments on commit 7c76010

Please sign in to comment.