mirror of
https://github.com/ChuckNorrison/LightningTipBot.git
synced 2026-08-19 13:18:12 +02:00
* lnurl comments for RECEIVING * fix import cycle * fix import * rename WebhookServer to Server * rename LNURLInvoice to Invoice * add str package. MarkdownEscape lnurl.Invoice comment * add str package * check for comment length * lnurl pay with comment * lnurl pay with comment * check for wallet existence * repackage main to internal Co-authored-by: lngohumble <lngohumble@gmail.com>
27 lines
598 B
Go
27 lines
598 B
Go
package str
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
var markdownV2Escapes = []string{"_", "[", "]", "(", ")", "~", "`", ">", "#", "+", "-", "=", "|", "{", "}", ".", "!"}
|
|
var markdownEscapes = []string{"_", "*", "`", "["}
|
|
|
|
func MarkdownV2Escape(s string) string {
|
|
for _, esc := range markdownV2Escapes {
|
|
if strings.Contains(s, esc) {
|
|
s = strings.Replace(s, esc, fmt.Sprintf("\\%s", esc), -1)
|
|
}
|
|
}
|
|
return s
|
|
}
|
|
|
|
func MarkdownEscape(s string) string {
|
|
for _, esc := range markdownEscapes {
|
|
if strings.Contains(s, esc) {
|
|
s = strings.Replace(s, esc, fmt.Sprintf("\\%s", esc), -1)
|
|
}
|
|
}
|
|
return s
|
|
}
|