Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement ctx.menu.at #14

Open
KnorpelSenf opened this issue Nov 16, 2021 · 0 comments
Open

feat: Implement ctx.menu.at #14

KnorpelSenf opened this issue Nov 16, 2021 · 0 comments

Comments

@KnorpelSenf
Copy link
Member

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.

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.

@KnorpelSenf KnorpelSenf changed the title Implement ctx.menu.at feat: Implement ctx.menu.at Dec 2, 2021
@KnorpelSenf KnorpelSenf moved this to To do in Coding Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: To do
Development

No branches or pull requests

2 participants