import { type MenuOptions } from "https://deno.land/x/grammy_menu@v1.2.2/menu.ts";
Configuration options for the menu.
Type Parameters
Properties
Menus will automatically call ctx.answerCallbackQuery
with no
arguments. If you want to call the method yourself, for example because
you need to send custom messages, you can set autoAnswer
to false
to
disable this behavior.
A menu is rendered once when it is sent, and once when a callback query arrives. After all, we could not store all rendered menus in all chats forever.
If a user presses a button on an old menu instance far up the chat, the buttons may have changed completely by now, and the menu would be rendered differently today. Consequently, this menu plugin can detect if the menu rendered based on the newly incoming callback query is the same as the menu that was sent originally.
If the menu is found to be outdated, no handlers are run. Instead, the old message is updated and a fresh menu is put into place. A notification is shown to the user that the menu was outdated. Long story short, you can use this option to personalize what notification to display. You can pass a string as the message to display to the user.
Alternatively, you can specify custom middleware that will be invoked and that can handle this case as you wish. You should update the menu yourself, or send a new message with the updated menu.
The default behavior is to display this message, and to update the menu: “Menu was outdated, try again!”
You can set onMenuOutdated
to false
to disable checks for outdated
menus altogether. In that case, the menu will behave as if the message
was no outdated, and run all handlers regardless.
Fingerprint function that lets you generate a unique string every time a menu is rendered. Used to determine if a menu is outdated. If specified, replaces the built-in heuristic.
The built-in heuristic that determines whether a menu is outdated takes the following things into account:
- identifier of the menu
- shape of the menu
- position of the pressed button
- potential payload
- text of the pressed button
If all of these things are identical but the menu is still outdated, you can use this option to supply the neccessary data that lets the menu plugin determine more accurately if the menu is outdated. Similarly, if any of these things differ but you want to consider the menu to be up to date, you can also use this option to signal that.
In other words, specifying a fingerprint function will replace the above heuristic entirely by your own implementation.