1.0.4 • Published 1 year ago

telegram-bot-markdown v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

💬 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.

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),
      },
    },
  ],
})
1.0.2

1 year ago

1.0.1

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.0

1 year ago