vlad-iakovlev / grammy-reply-with-markdown

replyWithMarkdown method for grammY
MIT License
1 stars 0 forks source link

grammy-reply-with-markdown

replyWithMarkdown method for grammY. Uses @vlad-yakovlev/telegram-md

GitHub CI Codecov NPM

Table of Contents

  1. How to Install
  2. Usage Examples

How to install

npm install @vlad-yakovlev/grammy-reply-with-markdown

Usage Examples

import { Bot, Context } from 'grammy';
import { ReplyWithMarkdownFlavour, replyWithMarkdownPlugin } from '@vlad-yakovlev/grammy-reply-with-markdown';
import { md } from 'telegram-md';

(async () => {
  const bot = new Bot<Context & ReplyWithMarkdownFlavour>('<bot-token>');

  bot.use(replyWithMarkdownPlugin());

  bot.command('start', async (ctx) => {
    // Send simple string (all special characters will be escaped)
    await ctx.replyWithMarkdown('Hello, World!');

    // Send Markdown (read more about `md` here: https://www.npmjs.org/package/telegram-md)
    await ctx.replyWithMarkdown(md`Hello, ${md.bold(World)}!`);

    // Options will be passed to ctx.reply
    await ctx.replyWithMarkdown('foo-bar', { reply_markup: { keyboard: [] });
  });
})()