Telegram Bot API 4.5 comes with new parse mode, MarkdownV2. At the same time these _ * [ ] ( ) ~ > # + - = | { } . !
characters must be escaped with the preceding character \
.
.replace(/[-.+?^$[\](){}\\]/g, '\\$&')
used as solution for adding escape character which works very well but unfortunately this solution does effect hyperlink method [inline URL](http://www.example.com/)
because it replace \[inline URL\]\(http://www.example\.com/\)
Solution
bot.on('text', (ctx) => {
const { chat } = ctx.message;
const msgs = `Here is the [rules](https://telegra.ph/rules-05-06) Please read carefully and give the details which mentioned below.
*Name:*
*Place:*
*Education:*
*Experience:*
You can also call me on (01234567890)
__For premium service please contact with admin__`;
const msgmsgWithEscape = msgs.replace(/[-.+?^$[\](){}\\]/g, '\\$&')
ctx.telegram.sendMessage(
chat.id,
msgmsgWithEscape,
{
parse_mode: 'MarkdownV2',
}
)
});
Result