-
Notifications
You must be signed in to change notification settings - Fork 11
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: Static menus #2
Comments
Depositing the phrases I queried the issues of this repo so that they may be indexed for others: this.id ContextQuestionGood evening all, a question about Menus and ctx: Suppose I wanted to use grammY bot in an ancillary webhook that does not receive updates from Telegram but payloads from another system e.g. a scheduled message. This message will contain a Menu, which depends on ctx to work; directly using Menu with bot.api.sendMessage(1234567, "good evening", {reply_markup: Menu} throws error Cannot send menu '${this.id}'! Did you forget to use bot.use() for it?. Actually, bot.use(Menu) is called before any other middleware. I am assuming that if I had access to a ctx, presumably via listener, Menu would work. If so, what listener could be triggered by a non-telegram-update payload? Has anyone any experience with sending menus in such a manner? Edit: Menu is an instance of the Menu class (from plugin) Answer@KnorpelSenf: What you should do instead is to use bot.api to send a message with reply markup, using the built-in keyboard plugin of grammY. As soon as a button is pressed, you can switch over to the menu plugin and let it handle the rest. |
Menus cannot be sent via
bot.api
because they require an installed API transformer. This transformer is only installed duringbot.use(menu)
.One way would be to directly provide the API transformer to be installed on
bot.api
, but this does not follow the intuitive pattern of the rest of the plugin.Instead, it would be cool if we can have a statically rendered version of the menu (a menu range) that can be passed to the constructor of the menu. Whenever the menu is sent (the internal
Proxy
is accessed), this static menu is rendered and sent. It obviously may not depend on a context object, so we should throw an error if someone tries to use dynamic strings/dynamic ranges.The text was updated successfully, but these errors were encountered: