2.1.2 • Published 10 months ago

@grammyjs/parse-mode v2.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Parse Mode plugin for grammY

This library provides simplified formatting utilities for the grammY Telegram Bot framework. It enables you to compose richly formatted messages using a declarative, type-safe API.

With this plugin, you can:

  • Use tagged template literals and formatters (like bold, italic, link, etc) to build formatted messages and captions
  • Apply formatting to text and media captions using the fmt function

The plugin is compatible with both Deno and Node.js, and is designed to work as a drop-in enhancement for grammY bots that need robust formatting capabilities.

Usage (Using fmt)

import { Bot } from "grammy";
import { fmt, b, u } from "@grammyjs/parse-mode";

const bot = new Bot("");

bot.command("demo", async (ctx) => {
 // Using return values of fmt
 const combined = fmt`${b}bolded${b} ${ctx.msg.text} ${u}underlined${u}`;
 await ctx.reply(combined.text { entities: combined.entities });
 await ctx.replyWithPhoto(photo { caption: combined.caption, caption_entities: combined.caption_entities });
});

bot.start();

Usage (Using FormattedString)

import { Bot } from "grammy";
import { FormattedString } from "@grammyjs/parse-mode";

const bot = new Bot("");

bot.command("demo", async (ctx) => {
 // Using return values of Fmt
 const combined = FormattedString.b("bolded").plain(ctx.msg.text).u("underlined");
 await ctx.reply(combined.text { entities: combined.entities });
 await ctx.replyWithPhoto(photo { caption: combined.caption, caption_entities: combined.caption_entities });
});

bot.start();
1.11.1

1 year ago

2.1.2

10 months ago

2.1.1

10 months ago

1.11.0

1 year ago

2.1.0

10 months ago

2.0.0

10 months ago

1.10.0

2 years ago

1.9.0

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.1

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.0

4 years ago

1.3.1

4 years ago

1.2.1

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.0.0

4 years ago

0.1.3

5 years ago