New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@grammyjs/parse-mode

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@grammyjs/parse-mode - npm Package Compare versions

Comparing version 1.0.0 to 1.1.1

dist/format.d.ts

2

dist/deps.node.d.ts
export type { Context, NextFunction, Transformer } from "grammy";
export * as GrammyTypes from "@grammyjs/types";
export type { MessageEntity, ParseMode } from "@grammyjs/types";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GrammyTypes = void 0;
exports.GrammyTypes = __importStar(require("@grammyjs/types"));

@@ -1,10 +0,12 @@

import type { Context, NextFunction } from './deps.node.js';
import type { Context, NextFunction } from "./deps.node.js";
import { type Stringable } from "./format.js";
declare type Tail<T extends Array<any>> = T extends [head: infer E1, ...tail: infer E2] ? E2 : [];
declare type ParseModeContext<C extends Context = Context> = C & {
replyWithHTML: C['reply'];
replyWithMarkdown: C['reply'];
replyWithMarkdownV1: C['reply'];
replyWithMarkdownV2: C['reply'];
replyFmt: (stringLike: Stringable, ...args: Tail<Parameters<C["reply"]>>) => ReturnType<C["reply"]>;
replyWithHTML: C["reply"];
replyWithMarkdown: C["reply"];
replyWithMarkdownV1: C["reply"];
replyWithMarkdownV2: C["reply"];
};
declare const middleware: <C extends ParseModeContext<Context>>(ctx: C, next: NextFunction) => Promise<void>;
export { middleware as hydrateReply };
export type { ParseModeContext };
export { middleware as hydrateReply, type ParseModeContext };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hydrateReply = void 0;
const buildFormattedReply = (parseMode, ctx) => {
const format_js_1 = require("./format.js");
const buildReplyWithParseMode = (parseMode, ctx) => {
return (...args) => {

@@ -11,8 +12,15 @@ const [text, payload, ...rest] = args;

const middleware = async (ctx, next) => {
ctx.replyWithHTML = buildFormattedReply('HTML', ctx);
ctx.replyWithMarkdown = buildFormattedReply('MarkdownV2', ctx);
ctx.replyWithMarkdownV1 = buildFormattedReply('Markdown', ctx);
ctx.replyWithMarkdownV2 = buildFormattedReply('MarkdownV2', ctx);
ctx.replyFmt = (stringLike, ...args) => {
const [payload, ...rest] = args;
const entities = stringLike instanceof format_js_1.FormattedString
? { entities: stringLike.entities }
: undefined;
return ctx.reply(stringLike.toString(), { ...payload, ...entities }, ...rest);
};
ctx.replyWithHTML = buildReplyWithParseMode("HTML", ctx);
ctx.replyWithMarkdown = buildReplyWithParseMode("MarkdownV2", ctx);
ctx.replyWithMarkdownV1 = buildReplyWithParseMode("Markdown", ctx);
ctx.replyWithMarkdownV2 = buildReplyWithParseMode("MarkdownV2", ctx);
return next();
};
exports.hydrateReply = middleware;

@@ -1,2 +0,3 @@

export * from './hydrate.js';
export * from './transformer.js';
export * from "./format.js";
export * from "./hydrate.js";
export * from "./transformer.js";

@@ -13,3 +13,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./format.js"), exports);
__exportStar(require("./hydrate.js"), exports);
__exportStar(require("./transformer.js"), exports);

@@ -1,3 +0,3 @@

import type { Transformer } from './deps.node.js';
import type { Transformer } from "./deps.node.js";
declare const buildTransformer: (parseMode: string) => Transformer<import("grammy").RawApi>;
export { buildTransformer as parseMode };

@@ -5,5 +5,5 @@ "use strict";

const wellKnownParseModesMap = new Map([
['html', 'HTML'],
['markdown', 'Markdown'],
['markdownv2', 'MarkdownV2'],
["html", "HTML"],
["markdown", "Markdown"],
["markdownv2", "MarkdownV2"],
]);

@@ -16,3 +16,3 @@ const buildTransformer = (parseMode) => {

const transformer = (prev, method, payload, signal) => {
if (!payload || 'parse_mode' in payload) {
if (!payload || "parse_mode" in payload) {
return prev(method, payload, signal);

@@ -19,0 +19,0 @@ }

{
"name": "@grammyjs/parse-mode",
"version": "1.0.0",
"version": "1.1.1",
"description": "Plugin for hydrating ctx with familiar reply variants and for setting default parse_mode",

@@ -10,3 +10,3 @@ "author": "KnightNiwrem",

"engines": {
"node": "^12.20.0 || >=14.13.1"
"node": ">=14.13.1"
},

@@ -28,5 +28,5 @@ "homepage": "https://github.com/grammyjs/parse-mode",

"@types/node": "^16.6.1",
"deno2node": "^1.0.0",
"grammy": "^1.3.1",
"typescript": "^4.3.5"
"deno2node": "^1.2.1",
"grammy": "^1.7.0",
"typescript": "^4.5.5"
},

@@ -33,0 +33,0 @@ "files": [

@@ -5,6 +5,27 @@ # Parse Mode plugin for grammY

## Usage
## Usage (Using format)
```ts
import { Bot, Composer } from 'grammy';
import { bold, fmt, hydrateReply, italic } from '@grammyjs/parse-mode';
import type { ParseModeContext } from '@grammyjs/parse-mode';
const bot = new Bot<ParseModeContext>('');
// 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`)}`);
});
bot.start();
```
## Usage (Using default parse mode and utility reply methods)
```ts
import { Bot, Composer } from 'grammy';
import { hydrateReply, parseMode } from 'parse-mode';

@@ -11,0 +32,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc