grammyjs / grammyjs/menu

feat: Implement `ctx.menu.at`

Open
#14 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
35
Forks
14
Avg merge
6h 39m
Merged PRs (30d)
2

Description

Allows to look up menu instances via the context object. They no longer have to be in scope.

This way, the menus can be defined in one file, and then imported and installed on the context object in the main file. They will be available in every other middleware in the code base.

This requires a new context flavour for menus, something that we were able to avoid thus far. However, given that it only really is necessary to be installed when that function is used, this should not be much of an issue.

The usage will be as follows.
```ts
await ctx.reply('Menu:', {
reply_markup: ctx.menu.at('id')
})
```

Regarding performance, a menu instance lookup is going to take `O(n)` time with `n` being the number of menu structures. Note that this number is equivalent to the number of menus passed to `bot.use` calls.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.