Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@grammyjs/parse-mode
Advanced tools
Plugin for hydrating ctx with familiar reply variants and for setting default parse_mode
This plugin provides a transformer for setting default parse_mode
, and a middleware for hydrating Context
with familiar reply
variant methods - i.e. replyWithHTML
, replyWithMarkdown
, etc.
import { Bot, Composer, Context } from 'grammy';
import { bold, fmt, hydrateReply, italic } from '@grammyjs/parse-mode';
import type { ParseModeFlavor } from '@grammyjs/parse-mode';
const bot = new Bot<ParseModeFlavor<Context>>('');
// Install format reply variant to ctx
bot.use(hydrateReply);
bot.command('demo', async ctx => {
await ctx.replyFmt(fmt`${bold('bold!')}
${bold(italic('bitalic!'))}
${bold(fmt`bold ${link('blink', 'example.com')} bold`)}`);
// fmt can also be called like a regular function
await ctx.replyFmt(fmt(['', ' and ', ' and ', ''], fmt`${bold('bold')}`, fmt`${bold(italic('bitalic'))}`, fmt`${italic('italic')}`));
});
bot.start();
import { Bot, Composer, Context } from 'grammy';
import { hydrateReply, parseMode } from '@grammyjs/parse-mode';
import type { ParseModeFlavor } from '@grammyjs/parse-mode';
const bot = new Bot<ParseModeFlavor<Context>>('');
// Install familiar reply variants to ctx
bot.use(hydrateReply);
// Sets default parse_mode for ctx.reply
bot.api.config.use(parseMode('MarkdownV2'));
bot.command('demo', async ctx => {
await ctx.reply('*This* is _the_ default `formatting`');
await ctx.replyWithHTML('<b>This</b> is <i>withHTML</i> <code>formatting</code>');
await ctx.replyWithMarkdown('*This* is _withMarkdown_ `formatting`');
await ctx.replyWithMarkdownV1('*This* is _withMarkdownV1_ `formatting`');
await ctx.replyWithMarkdownV2('*This* is _withMarkdownV2_ `formatting`');
});
bot.start();
FAQs
Plugin for hydrating ctx with familiar reply variants and for setting default parse_mode
The npm package @grammyjs/parse-mode receives a total of 2,165 weekly downloads. As such, @grammyjs/parse-mode popularity was classified as popular.
We found that @grammyjs/parse-mode demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.