telegram-bot-api
telegram-bot-api copied to clipboard
Fix EscapeText for MarkdownV2.
This pull request is pretty straight forward...
Telegram documentation says:
Any character with code between 1 and 126 inclusively can be escaped anywhere with a preceding '' character, in which case it is treated as an ordinary character and not a part of the markup. This implies that '\' character usually must be escaped with a preceding '\' character.
Source: https://core.telegram.org/bots/api#markdownv2-style
So here goes a simple sample program to simulate the bug:
package main
import (
"fmt"
tg "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
func main() {
fmt.Println(tg.EscapeText(tg.ModeMarkdownV2, `a\b`))
fmt.Println(tg.EscapeText(tg.ModeMarkdownV2, `a\(b)c`))
}
Before the fix:
a\b
a\\(b\)c
After the fix:
a\\b
a\\\(b\)c
In the first example: the message will be send like "ab" (the slash will disappear)
In the second example:
the message will not be sent, it will error out something like this:
Bad Request: can't parse entities: Character '(' is reserved and must be escaped with the preceding '\'
It's a small fix, but an important one.
[]'s
Is this package still maintained?