telegram-bot-markdown
v1.0.4
Published
💬 Markdown helpers for Telegram Bot
Downloads
2
Readme
💬 Markdown helpers for Telegram Bot
Installation
npm i telegram-bot-markdown
Features
Escape markdown
When you send a message in markdown format, you must escape special characters. This package will help you do that.
- Official information about markdown on Telegram.
- Issues: 1, 2, 3
import { escapeMarkdown } from 'telegram-bot-markdown'
const markdownMessage = `Hello, *world*! ${escapeMarkdown('(text with special characters!)')}`
Generate markdown by template
A special template for generating messages in markdown format. Allows you to keep all messages in the same form using a strict template. Useful for DX and UI/UX.
import { generateMarkdown } from 'telegram-bot-markdown'
const markdownMessage = generateMarkdown({
title: 'Title',
description: 'Description',
items: [
{
type: 'STRING',
data: 'String item',
},
{
type: 'LINEBREAK',
},
{
type: 'KEY_VALUE',
data: {
key: 'Key',
value: 'Value',
},
},
{
type: 'KEY_VALUE',
data: {
key: 'Key 2',
value: 'Value 2',
valueType: 'code',
},
},
{
type: 'LINEBREAK',
},
{
type: 'CODE_BLOCK',
data: {
lang: 'json',
code: JSON.stringify({ code: 'block' }, null, 2),
},
},
],
})