telegram-escape
Lightweight Javascript utility zero-dependecy library for Telegram Bots developers for escaping user input with formatting options
Installation
npm i telegram-escape
Usage examples
const { HTML } = require("telegram-escape");
const firstName = "<My Cool Name>";
await bot.sendMessage(chatId, HTML`<b>${firstName}</b>`, {
parse_mode: "HTML",
}); // bold "<My Cool Name>"
await bot.sendMessage(chatId, HTML`<b>${"2 < 3"}</b>`, {
parse_mode: "HTML",
}); // bold "2 < 3"
const { md } = require("telegram-escape");
const firstName = "*My Cool Name*";
await bot.sendMessage(chatId, md`_${firstName}_`, {
parse_mode: "MarkdownV2",
}); // italic "*My Cool Name*"
Functions
-
HTML`template_${string}` ⇒
String
-
md`template_${string}` ⇒
String
-
mdv1`template_${string}` ⇒
String
-
escapeHTML(text) ⇒
String
-
escapeMarkdown(text) ⇒
String
-
escapeMarkdownV1(text) ⇒
String
String
HTML`template_${string}`⇒
String
md`template_${string}`⇒
String
mdv1`template_${string}`⇒
String
escapeHTML(text) ⇒ Kind: global function
Param | Type |
---|---|
text | String |
String
escapeMarkdown(text) ⇒ Kind: global function
Param | Type |
---|---|
text | String |
String
escapeMarkdownV1(text) ⇒ Kind: global function
Param | Type |
---|---|
text | String |