🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@grammyjs/parse-mode

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@grammyjs/parse-mode

Plugin for constructing Formatted Texts in Telegram

2.2.0
latest
Source
npm
Version published
Weekly downloads
3.1K
-4.32%
Maintainers
2
Weekly downloads
 
Created
Source

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();

Keywords

bot

FAQs

Package last updated on 29 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts