Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grammy-inline-menu

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grammy-inline-menu - npm Package Compare versions

Comparing version 8.0.0 to 8.0.1

8

dist/source/action-hive.d.ts

@@ -1,7 +0,7 @@

import { ContextPathFunc, RegExpLike, ConstOrPromise } from './generic-types.js';
export declare type ActionFunc<Context> = (context: Context, path: string) => ConstOrPromise<string | boolean>;
export interface ButtonAction<Context> {
import type { ConstOrPromise, ContextPathFunc, RegExpLike } from './generic-types.js';
export type ActionFunc<Context> = (context: Context, path: string) => ConstOrPromise<string | boolean>;
export type ButtonAction<Context> = {
readonly trigger: RegExpLike;
readonly doFunction: ActionFunc<Context>;
}
};
export declare class ActionHive<Context> {

@@ -8,0 +8,0 @@ private readonly _actions;

@@ -1,26 +0,27 @@

import { InputFile } from 'grammy';
import { LabeledPrice, Location, ParseMode, Venue } from '@grammyjs/types';
import { ReadonlyDeep } from 'type-fest';
export declare type Body = string | TextBody | MediaBody | LocationBody | VenueBody | InvoiceBody;
export declare type MediaType = 'animation' | 'audio' | 'document' | 'photo' | 'video';
export declare const MEDIA_TYPES: readonly MediaType[];
interface TextPart {
import type { InputFile } from 'grammy';
import type { LabeledPrice, Location, ParseMode, Venue } from 'grammy/types';
import type { ReadonlyDeep } from 'type-fest';
export type Body = string | TextBody | MediaBody | LocationBody | VenueBody | InvoiceBody;
export declare const MEDIA_TYPES: readonly ["animation", "audio", "document", "photo", "video"];
export type MediaType = typeof MEDIA_TYPES[number];
export type TextBody = {
readonly text: string;
readonly parse_mode?: ParseMode;
}
export interface TextBody extends TextPart {
readonly disable_web_page_preview?: boolean;
}
export interface MediaBody extends Partial<TextPart> {
};
export type MediaBody = {
readonly type: MediaType;
readonly media: string | InputFile;
}
export interface LocationBody {
/** Caption */
readonly text?: string;
readonly parse_mode?: ParseMode;
};
export type LocationBody = {
readonly location: Readonly<Location>;
readonly live_period?: number;
}
export interface VenueBody {
};
export type VenueBody = {
readonly venue: ReadonlyDeep<Venue>;
}
export interface InvoiceBody {
};
export type InvoiceBody = {
readonly invoice: {

@@ -34,3 +35,3 @@ readonly title: string;

};
}
};
export declare function isTextBody(body: unknown): body is string | TextBody;

@@ -42,2 +43,1 @@ export declare function isMediaBody(body: unknown): body is MediaBody;

export declare function getBodyText(body: TextBody | string): string;
export {};

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

const generic_types_js_1 = require("./generic-types.js");
exports.MEDIA_TYPES = ['animation', 'audio', 'document', 'photo', 'video'];
exports.MEDIA_TYPES = [
'animation',
'audio',
'document',
'photo',
'video',
];
function isKnownMediaType(type) {

@@ -8,0 +14,0 @@ if (typeof type !== 'string') {

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

import { ContextPathFunc } from '../generic-types.js';
import type { ContextPathFunc } from '../generic-types.js';
export interface BasicOptions<Context> {

@@ -3,0 +3,0 @@ /**

@@ -1,4 +0,4 @@

import { ConstOrPromise } from '../generic-types.js';
import { ManyChoicesOptions } from '../choices/index.js';
export declare type ChooseActionFunc<Context> = (context: Context, key: string) => ConstOrPromise<string | boolean>;
import type { ConstOrPromise } from '../generic-types.js';
import type { ManyChoicesOptions } from '../choices/index.js';
export type ChooseActionFunc<Context> = (context: Context, key: string) => ConstOrPromise<string | boolean>;
export interface ChooseOptions<Context> extends ManyChoicesOptions<Context> {

@@ -5,0 +5,0 @@ /**

@@ -1,6 +0,6 @@

import { ContextFunc, ConstOrPromise } from '../generic-types.js';
import { BasicOptions } from './basic.js';
export declare type SetPageFunction<Context> = (context: Context, page: number) => ConstOrPromise<void>;
export declare type GetCurrentPageFunction<Context> = ContextFunc<Context, number | undefined>;
export declare type GetTotalPagesFunction<Context> = ContextFunc<Context, number>;
import type { ConstOrPromise, ContextFunc } from '../generic-types.js';
import type { BasicOptions } from './basic.js';
export type SetPageFunction<Context> = (context: Context, page: number) => ConstOrPromise<void>;
export type GetCurrentPageFunction<Context> = ContextFunc<Context, number | undefined>;
export type GetTotalPagesFunction<Context> = ContextFunc<Context, number>;
export interface GenericPaginationOptions<Context> {

@@ -7,0 +7,0 @@ /**

@@ -1,7 +0,7 @@

import { CallbackButtonTemplate } from '../keyboard.js';
import { ConstOrPromise, ConstOrContextFunc } from '../generic-types.js';
import { ManyChoicesOptions, Choices } from '../choices/index.js';
export declare type IsSetFunction<Context> = (context: Context, key: string) => ConstOrPromise<boolean>;
export declare type SetFunction<Context> = (context: Context, key: string, newState: boolean) => ConstOrPromise<string | boolean>;
export declare type FormatStateFunction<Context> = (context: Context, textResult: string, state: boolean, key: string) => ConstOrPromise<string>;
import type { CallbackButtonTemplate } from '../keyboard.js';
import type { Choices, ManyChoicesOptions } from '../choices/index.js';
import type { ConstOrContextFunc, ConstOrPromise } from '../generic-types.js';
export type IsSetFunction<Context> = (context: Context, key: string) => ConstOrPromise<boolean>;
export type SetFunction<Context> = (context: Context, key: string, newState: boolean) => ConstOrPromise<string | boolean>;
export type FormatStateFunction<Context> = (context: Context, textResult: string, state: boolean, key: string) => ConstOrPromise<string>;
export interface SelectOptions<Context> extends ManyChoicesOptions<Context> {

@@ -8,0 +8,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateSelectButtons = void 0;
const index_js_1 = require("../choices/index.js");
const understand_choices_js_1 = require("../choices/understand-choices.js");
const index_js_1 = require("../choices/index.js");
const prefix_js_1 = require("../prefix.js");

@@ -7,0 +7,0 @@ const align_js_1 = require("./align.js");

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

import { ManyChoicesOptions } from '../choices/index.js';
import { SingleButtonOptions } from './basic.js';
import type { ManyChoicesOptions } from '../choices/index.js';
import type { SingleButtonOptions } from './basic.js';
export interface SubmenuOptions<Context> extends SingleButtonOptions<Context> {

@@ -4,0 +4,0 @@ }

@@ -1,5 +0,5 @@

import { CallbackButtonTemplate } from '../keyboard.js';
import { ContextPathFunc, ConstOrPromise, ConstOrContextPathFunc } from '../generic-types.js';
import { SingleButtonOptions } from './basic.js';
export declare type FormatStateFunction<Context> = (context: Context, text: string, state: boolean, path: string) => ConstOrPromise<string>;
import type { CallbackButtonTemplate } from '../keyboard.js';
import type { ConstOrContextPathFunc, ConstOrPromise, ContextPathFunc } from '../generic-types.js';
import type { SingleButtonOptions } from './basic.js';
export type FormatStateFunction<Context> = (context: Context, text: string, state: boolean, path: string) => ConstOrPromise<string>;
export interface ToggleOptions<Context> extends SingleButtonOptions<Context> {

@@ -6,0 +6,0 @@ /**

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

import { ConstOrContextFunc, ContextPathFunc } from '../generic-types.js';
import { Choices } from './types.js';
import type { ConstOrContextFunc, ContextPathFunc } from '../generic-types.js';
import type { Choices } from './types.js';
export declare function combineHideAndChoices<Context>(actionPrefix: string, choices: ConstOrContextFunc<Context, Choices>, hide: undefined | ContextPathFunc<Context, boolean>): ContextPathFunc<Context, boolean>;

@@ -1,6 +0,6 @@

import { CallbackButtonTemplate } from '../keyboard.js';
import { ConstOrContextFunc } from '../generic-types.js';
import { Choices, ManyChoicesOptions, ChoiceTextFunc } from './types.js';
import type { CallbackButtonTemplate } from '../keyboard.js';
import type { ConstOrContextFunc } from '../generic-types.js';
import type { Choices, ChoiceTextFunc, ManyChoicesOptions } from './types.js';
export declare function generateChoicesButtons<Context>(actionPrefix: string, isSubmenu: boolean, choices: ConstOrContextFunc<Context, Choices>, options: ManyChoicesOptions<Context>): (context: Context, path: string) => Promise<CallbackButtonTemplate[][]>;
export declare function generateChoicesPaginationButtons<Context>(actionPrefix: string, choiceKeys: number, currentPage: number | undefined, options: ManyChoicesOptions<Context>): CallbackButtonTemplate[];
export declare function createChoiceTextFunction<Context>(choices: Choices, buttonText: undefined | ChoiceTextFunc<Context>): ChoiceTextFunc<Context>;

@@ -1,11 +0,11 @@

import { BasicOptions } from '../buttons/basic.js';
import { ConstOrPromise } from '../generic-types.js';
import { GenericPaginationOptions } from '../buttons/pagination.js';
export declare type Choice = string | number;
export declare type ChoiceText = string;
export declare type ChoicesArray = readonly Choice[];
export declare type ChoicesRecord = Readonly<Record<Choice, ChoiceText>>;
export declare type ChoicesMap = Readonly<ReadonlyMap<Choice, ChoiceText>>;
export declare type Choices = ChoicesArray | ChoicesRecord | ChoicesMap;
export declare type ChoiceTextFunc<Context> = (context: Context, key: string) => ConstOrPromise<string>;
import type { BasicOptions } from '../buttons/basic.js';
import type { ConstOrPromise } from '../generic-types.js';
import type { GenericPaginationOptions } from '../buttons/pagination.js';
export type Choice = string | number;
export type ChoiceText = string;
export type ChoicesArray = readonly Choice[];
export type ChoicesRecord = Readonly<Record<Choice, ChoiceText>>;
export type ChoicesMap = Readonly<ReadonlyMap<Choice, ChoiceText>>;
export type Choices = ChoicesArray | ChoicesRecord | ChoicesMap;
export type ChoiceTextFunc<Context> = (context: Context, key: string) => ConstOrPromise<string>;
export interface ManyChoicesOptions<Context> extends BasicOptions<Context>, Partial<GenericPaginationOptions<Context>> {

@@ -12,0 +12,0 @@ /**

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

import { Choices, ChoicesArray, ChoicesMap } from './types.js';
import type { Choices, ChoicesArray, ChoicesMap } from './types.js';
export declare function choicesIsArray(choices: Choices): choices is ChoicesArray;

@@ -3,0 +3,0 @@ export declare function choicesIsMap(choices: Choices): choices is ChoicesMap;

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

export declare type ConstOrPromise<T> = T | Promise<T>;
export declare type ContextFunc<Context, ReturnType> = (context: Context) => ConstOrPromise<ReturnType>;
export declare type ContextPathFunc<Context, ReturnType> = (context: Context, path: string) => ConstOrPromise<ReturnType>;
export declare type ConstOrContextFunc<Context, ReturnType> = ReturnType | ContextFunc<Context, ReturnType>;
export declare type ConstOrContextPathFunc<Context, ReturnType> = ReturnType | ContextPathFunc<Context, ReturnType>;
export interface RegExpLike {
export type ConstOrPromise<T> = T | Promise<T>;
export type ContextFunc<Context, ReturnType> = (context: Context) => ConstOrPromise<ReturnType>;
export type ContextPathFunc<Context, ReturnType> = (context: Context, path: string) => ConstOrPromise<ReturnType>;
export type ConstOrContextFunc<Context, ReturnType> = ReturnType | ContextFunc<Context, ReturnType>;
export type ConstOrContextPathFunc<Context, ReturnType> = ReturnType | ContextPathFunc<Context, ReturnType>;
export type RegExpLike = {
readonly source: string;
readonly flags?: string;
}
};
export declare function isObject(something: unknown): something is Record<string, unknown>;

@@ -11,0 +11,0 @@ export declare function hasTruthyKey(something: unknown, key: string): boolean;

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

export { Body } from './body.js';
export { getMenuOfPath } from './path.js';

@@ -7,1 +6,2 @@ export * from './menu-middleware.js';

export * from './send-menu.js';
export type { Body } from './body.js';

@@ -1,14 +0,14 @@

import { InlineKeyboardButton as TelegramInlineKeyboardButton } from '@grammyjs/types';
import { ReadonlyDeep } from 'type-fest';
import { ConstOrContextPathFunc, ContextPathFunc } from './generic-types.js';
export interface CallbackButtonTemplate {
import type { InlineKeyboardButton as TelegramInlineKeyboardButton } from 'grammy/types';
import type { ReadonlyDeep } from 'type-fest';
import type { ConstOrContextPathFunc, ContextPathFunc } from './generic-types.js';
export type CallbackButtonTemplate = {
readonly text: string;
readonly relativePath: string;
}
export declare type InlineKeyboardButton = ReadonlyDeep<TelegramInlineKeyboardButton>;
export declare type InlineKeyboard = ReadonlyArray<readonly InlineKeyboardButton[]>;
export declare type ButtonTemplate = CallbackButtonTemplate | InlineKeyboardButton;
export declare type ButtonTemplateRow = readonly ButtonTemplate[];
declare type UncreatedTemplate<Context> = ConstOrContextPathFunc<Context, ButtonTemplate | undefined>;
declare type ButtonTemplateRowGenerator<Context> = ContextPathFunc<Context, ButtonTemplateRow[]>;
};
export type InlineKeyboardButton = ReadonlyDeep<TelegramInlineKeyboardButton>;
export type InlineKeyboard = ReadonlyArray<readonly InlineKeyboardButton[]>;
export type ButtonTemplate = CallbackButtonTemplate | InlineKeyboardButton;
export type ButtonTemplateRow = readonly ButtonTemplate[];
type UncreatedTemplate<Context> = ConstOrContextPathFunc<Context, ButtonTemplate | undefined>;
type ButtonTemplateRowGenerator<Context> = ContextPathFunc<Context, ButtonTemplateRow[]>;
export declare class Keyboard<Context> {

@@ -15,0 +15,0 @@ private readonly _entries;

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

const node_buffer_1 = require("node:buffer");
const path_js_1 = require("./path.js");
const generic_types_js_1 = require("./generic-types.js");
const path_js_1 = require("./path.js");
function isRow(entry) {

@@ -9,0 +9,0 @@ return Array.isArray(entry);

@@ -1,6 +0,6 @@

import { Body } from './body.js';
import { ButtonAction } from './action-hive.js';
import { ContextPathFunc, RegExpLike } from './generic-types.js';
import { InlineKeyboard } from './keyboard.js';
export interface MenuLike<Context> {
import type { Body } from './body.js';
import type { ButtonAction } from './action-hive.js';
import type { ContextPathFunc, RegExpLike } from './generic-types.js';
import type { InlineKeyboard } from './keyboard.js';
export type MenuLike<Context> = {
readonly renderBody: ContextPathFunc<Context, Body>;

@@ -10,7 +10,7 @@ readonly renderKeyboard: ContextPathFunc<Context, InlineKeyboard>;

readonly listSubmenus: () => ReadonlySet<Submenu<Context>>;
}
export interface Submenu<Context> {
};
export type Submenu<Context> = {
readonly action: RegExpLike;
readonly hide: undefined | ContextPathFunc<Context, boolean>;
readonly menu: MenuLike<Context>;
}
};

@@ -1,6 +0,6 @@

import { Context as BaseContext } from 'grammy';
import { RegExpLike } from './generic-types.js';
import { MenuLike } from './menu-like.js';
import { SendMenuFunc } from './send-menu.js';
export interface Options<Context> {
import type { Context as BaseContext } from 'grammy';
import type { RegExpLike } from './generic-types.js';
import type { MenuLike } from './menu-like.js';
import type { SendMenuFunc } from './send-menu.js';
export type Options<Context> = {
/**

@@ -12,3 +12,3 @@ * Function which is used to send and update the menu.

readonly sendMenu?: SendMenuFunc<Context>;
}
};
export declare class MenuMiddleware<Context extends BaseContext> {

@@ -15,0 +15,0 @@ readonly rootTrigger: string | RegExpLike;

@@ -86,2 +86,3 @@ "use strict";

if (match?.[0] && responder.type === 'action') {
// @ts-expect-error grammy has some more specific type there
context.match = match;

@@ -109,4 +110,6 @@ const afterwardsTarget = await responder.do(context, match[0]);

}
// @ts-expect-error grammy has some more specific type there
context.match = match;
const targetPath = match[0];
// @ts-expect-error menu context is not exactly the context type (callback query context vs base context)
await this._sendMenu(responder.menu, context, targetPath);

@@ -113,0 +116,0 @@ await context.answerCallbackQuery()

@@ -1,13 +0,13 @@

import { Body } from './body.js';
import { ButtonAction, ActionFunc } from './action-hive.js';
import { Choices } from './choices/index.js';
import { ChooseOptions } from './buttons/choose.js';
import { ContextPathFunc, ConstOrContextFunc, ConstOrContextPathFunc, RegExpLike } from './generic-types.js';
import { ButtonTemplate, ButtonTemplateRow, InlineKeyboard } from './keyboard.js';
import { MenuLike, Submenu } from './menu-like.js';
import { PaginationOptions } from './buttons/pagination.js';
import { SelectOptions } from './buttons/select.js';
import { SingleButtonOptions } from './buttons/basic.js';
import { SubmenuOptions, ChooseIntoSubmenuOptions } from './buttons/submenu.js';
import { ToggleOptions } from './buttons/toggle.js';
import type { ActionFunc, ButtonAction } from './action-hive.js';
import type { Body } from './body.js';
import type { ButtonTemplate, ButtonTemplateRow, InlineKeyboard } from './keyboard.js';
import type { Choices } from './choices/index.js';
import type { ChooseIntoSubmenuOptions, SubmenuOptions } from './buttons/submenu.js';
import type { ChooseOptions } from './buttons/choose.js';
import type { ConstOrContextFunc, ConstOrContextPathFunc, ContextPathFunc, RegExpLike } from './generic-types.js';
import type { MenuLike, Submenu } from './menu-like.js';
import type { PaginationOptions } from './buttons/pagination.js';
import type { SelectOptions } from './buttons/select.js';
import type { SingleButtonOptions } from './buttons/basic.js';
import type { ToggleOptions } from './buttons/toggle.js';
export interface InteractionOptions<Context> extends SingleButtonOptions<Context> {

@@ -14,0 +14,0 @@ /**

@@ -6,7 +6,7 @@ "use strict";

const index_js_1 = require("./choices/index.js");
const pagination_js_1 = require("./buttons/pagination.js");
const path_js_1 = require("./path.js");
const keyboard_js_1 = require("./keyboard.js");
const pagination_js_1 = require("./buttons/pagination.js");
const select_js_1 = require("./buttons/select.js");
const toggle_js_1 = require("./buttons/toggle.js");
const keyboard_js_1 = require("./keyboard.js");
class MenuTemplate {

@@ -13,0 +13,0 @@ constructor(

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

import { RegExpLike } from './generic-types.js';
import type { RegExpLike } from './generic-types.js';
export declare function ensureTriggerChild(trigger: string | RegExpLike): void;

@@ -3,0 +3,0 @@ export declare function ensureTriggerLastChild(trigger: string | RegExpLike): void;

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

export interface PrefixOptions {
export type PrefixOptions = {
/**

@@ -22,3 +22,3 @@ * Emoji which is used as prefix when true.

readonly hideFalseEmoji?: boolean;
}
};
export declare const emojiTrue = "\u2705";

@@ -25,0 +25,0 @@ export declare const emojiFalse = "\uD83D\uDEAB";

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

import { CallbackButtonTemplate } from '../keyboard.js';
import { ConstOrContextPathFunc } from '../generic-types.js';
import type { CallbackButtonTemplate } from '../keyboard.js';
import type { ConstOrContextPathFunc } from '../generic-types.js';
export declare function createBackMainMenuButtons<Context>(backButtonText?: ConstOrContextPathFunc<Context, string>, mainMenuButtonText?: ConstOrContextPathFunc<Context, string>): (context: Context, path: string) => Promise<CallbackButtonTemplate[][]>;

@@ -1,8 +0,8 @@

import { Context as BaseContext, Api } from 'grammy';
import { Message } from '@grammyjs/types';
import { MenuLike } from './menu-like.js';
import type { Api, Context as BaseContext } from 'grammy';
import type { Message } from 'grammy/types';
import type { MenuLike } from './menu-like.js';
/**
* Generic Method which is able to send a menu to a context (given a path where it is)
*/
export declare type SendMenuFunc<Context> = (menu: MenuLike<Context>, context: Context, path: string) => Promise<unknown>;
export type SendMenuFunc<Context> = (menu: MenuLike<Context>, context: Context, path: string) => Promise<unknown>;
/**

@@ -12,3 +12,3 @@ * Method which is able to send a menu to a chat.

*/
export declare type SendMenuToChatFunction<Context> = (chatId: string | number, context: Context, other?: Readonly<Record<string, unknown>>) => Promise<Message>;
export type SendMenuToChatFunction<Context> = (chatId: string | number, context: Context, other?: Readonly<Record<string, unknown>>) => Promise<Message>;
/**

@@ -18,3 +18,3 @@ * Method which is able to edit a message in a chat into a menu.

*/
export declare type EditMessageIntoMenuFunction<Context> = (chatId: number | string, messageId: number, context: Context, other?: Readonly<Record<string, unknown>>) => Promise<Message | true>;
export type EditMessageIntoMenuFunction<Context> = (chatId: number | string, messageId: number, context: Context, other?: Readonly<Record<string, unknown>>) => Promise<Message | true>;
/**

@@ -35,3 +35,3 @@ * Reply a menu to a context as a new message

*/
export declare function editMenuOnContext<Context extends BaseContext>(menu: MenuLike<Context>, context: Context, path: string, other?: Readonly<Record<string, unknown>>): Promise<boolean | Message.DocumentMessage | Message.AudioMessage | Message.PhotoMessage | Message.VideoMessage | Message.LocationMessage | Message.InvoiceMessage | Message.TextMessage>;
export declare function editMenuOnContext<Context extends BaseContext>(menu: MenuLike<Context>, context: Context, path: string, other?: Readonly<Record<string, unknown>>): Promise<boolean | Message.DocumentMessage | Message.AudioMessage | Message.PhotoMessage | Message.VideoMessage | Message.LocationMessage | Message.InvoiceMessage | Message.TextMessage | (import("grammy/types").Update.Edited & Message)>;
/**

@@ -57,3 +57,3 @@ * Delete the message on the context.

*/
export declare function generateSendMenuToChatFunction<Context>(telegram: Readonly<Api>, menu: MenuLike<Context>, path: string): SendMenuToChatFunction<Context>;
export declare function generateSendMenuToChatFunction<Context>(telegram: Api, menu: MenuLike<Context>, path: string): SendMenuToChatFunction<Context>;
/**

@@ -66,2 +66,2 @@ * Edit the message into the the menu.

*/
export declare function generateEditMessageIntoMenuFunction<Context>(telegram: Readonly<Api>, menu: MenuLike<Context>, path: string): EditMessageIntoMenuFunction<Context>;
export declare function generateEditMessageIntoMenuFunction<Context>(telegram: Api, menu: MenuLike<Context>, path: string): EditMessageIntoMenuFunction<Context>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateEditMessageIntoMenuFunction = exports.generateSendMenuToChatFunction = exports.resendMenuToContext = exports.deleteMenuFromContext = exports.editMenuOnContext = exports.replyMenuToContext = void 0;
const path_js_1 = require("./path.js");
const body_js_1 = require("./body.js");
const path_js_1 = require("./path.js");
/**

@@ -103,4 +103,5 @@ * Reply a menu to a context as a new message

}
async function replyRenderedMenuPartsToContext(
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
async function replyRenderedMenuPartsToContext(body, keyboard, context, other = {}) {
body, keyboard, context, other = {}) {
if ((0, body_js_1.isMediaBody)(body)) {

@@ -110,12 +111,17 @@ const mediaOther = createSendMediaOther(body, keyboard, other);

switch (body.type) {
case 'animation':
case 'animation': {
return context.replyWithAnimation(body.media, mediaOther);
case 'audio':
}
case 'audio': {
return context.replyWithAudio(body.media, mediaOther);
case 'document':
}
case 'document': {
return context.replyWithDocument(body.media, mediaOther);
case 'photo':
}
case 'photo': {
return context.replyWithPhoto(body.media, mediaOther);
case 'video':
}
case 'video': {
return context.replyWithVideo(body.media, mediaOther);
}
}

@@ -146,4 +152,5 @@ }

*/
function generateSendMenuToChatFunction(
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
function generateSendMenuToChatFunction(telegram, menu, path) {
telegram, menu, path) {
return async (chatId, context, other = {}) => {

@@ -156,12 +163,17 @@ const body = await menu.renderBody(context, path);

switch (body.type) {
case 'animation':
case 'animation': {
return telegram.sendAnimation(chatId, body.media, mediaOther);
case 'audio':
}
case 'audio': {
return telegram.sendAudio(chatId, body.media, mediaOther);
case 'document':
}
case 'document': {
return telegram.sendDocument(chatId, body.media, mediaOther);
case 'photo':
}
case 'photo': {
return telegram.sendPhoto(chatId, body.media, mediaOther);
case 'video':
}
case 'video': {
return telegram.sendVideo(chatId, body.media, mediaOther);
}
}

@@ -195,4 +207,5 @@ }

*/
function generateEditMessageIntoMenuFunction(
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
function generateEditMessageIntoMenuFunction(telegram, menu, path) {
telegram, menu, path) {
return async (chatId, messageId, context, other = {}) => {

@@ -236,4 +249,5 @@ const body = await menu.renderBody(context, path);

}
function createSendMediaOther(
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
function createSendMediaOther(body, keyboard, base) {
body, keyboard, base) {
return {

@@ -240,0 +254,0 @@ ...base,

{
"name": "grammy-inline-menu",
"version": "8.0.0",
"version": "8.0.1",
"description": "Inline Menus for Telegram made simple. Successor of telegraf-inline-menu.",

@@ -17,3 +17,6 @@ "keywords": [

"license": "MIT",
"repository": "EdJoPaTo/grammy-inline-menu",
"repository": {
"type": "git",
"url": "https://github.com/EdJoPaTo/grammy-inline-menu.git"
},
"bugs": {

@@ -33,3 +36,3 @@ "url": "https://github.com/EdJoPaTo/grammy-inline-menu/issues"

"example-js": "node examples/main-javascript.mjs",
"start": "ts-node examples/main-typescript.ts",
"start": "tsc --sourceMap && node --enable-source-maps dist/examples/main-typescript.js",
"test": "tsc --sourceMap && xo && nyc ava"

@@ -42,6 +45,6 @@ },

"dependencies": {
"@grammyjs/types": "^2.2.6"
"type-fest": "^3.0.0"
},
"peerDependencies": {
"grammy": "^1.3.0"
"grammy": "^1.10.1"
},

@@ -51,11 +54,13 @@ "devDependencies": {

"@types/node": "^14.18.21",
"ava": "^4.0.0",
"del-cli": "^4.0.0",
"grammy": "^1.3.0",
"ava": "^5.0.1",
"del-cli": "^5.0.0",
"grammy": "^1.10.1",
"nyc": "^15.0.0",
"ts-node": "^10.0.0",
"type-fest": "^2.11.2",
"typescript": "^4.4.4",
"xo": "^0.50.0"
"typescript": "^5.0.2",
"xo": "^0.54.0"
},
"files": [
"dist/source",
"!*.test.*"
],
"main": "./dist/source/index.js",

@@ -77,2 +82,3 @@ "types": "./dist/source/index.d.ts",

"rules": {
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/naming-convention": "off",

@@ -101,8 +107,9 @@ "@typescript-eslint/prefer-readonly-parameter-types": "error",

"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"ava/no-skip-test": "warn",
"max-params": "off"
"max-params": "off",
"unicorn/prefer-top-level-await": "off"
}

@@ -109,0 +116,0 @@ }

@@ -86,3 +86,3 @@ # grammY Inline Menu

Version 7 switches from Telegraf to grammY as a Telegram Bot framework.
Version 7 switches from Telegraf to [grammY](https://github.com/grammyjs/grammY) as a Telegram Bot framework.
grammY has various benefits over Telegraf as Telegraf is quite old and grammY learned a lot from its mistakes and shortcomings.

@@ -384,3 +384,3 @@

```ts
const submenu = new MenuTemplate<MyContext>('I am a submenu')
const submenuTemplate = new MenuTemplate<MyContext>('I am a submenu')
submenuTemplate.interact('Text', 'unique', {

@@ -387,0 +387,0 @@ do: async ctx => ctx.answerCallbackQuery('You hit a button in a submenu')

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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