telegram-escape
v1.1.1
Published
Lightweight Javascript utility zero-dependecy library for Telegram Bots developers for escaping user input with formatting options
Downloads
202
Readme
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
Kind: global function
md`template_${string}`⇒ String
Kind: global function
mdv1`template_${string}`⇒ String
Kind: global function
escapeHTML(text) ⇒ String
Kind: global function
| Param | Type | | ----- | ------------------- | | text | String |
escapeMarkdown(text) ⇒ String
Kind: global function
| Param | Type | | ----- | ------------------- | | text | String |
escapeMarkdownV1(text) ⇒ String
Kind: global function
| Param | Type | | ----- | ------------------- | | text | String |