EdJoPaTo / grammy-inline-menu

Inline Menus for Telegram made simple. Successor of telegraf-inline-menu.
MIT License
357 stars 44 forks source link

Ability to refresh/redraw /update the menu on external event #169

Closed efimd closed 3 years ago

efimd commented 3 years ago

Describe your goal I am using the menu to manage my alarm system in the house. Simplistically it has 1 button with the text of the state of the alarm. Once pressed the alarm state is changed and the button refreshes the text. The problem is that if the alarm state changes externally (someone disarms it using the keypad) I would like to somehow "redraw" the current menu or submenu. In other words a separate event causes a state change. I have a handler for such a state change and I want to "redraw"/update the current menu. Can not seem to find a way to do it.

EdJoPaTo commented 3 years ago

I think you seek the generateEditMessageIntoMenuFunction:

https://github.com/EdJoPaTo/telegraf-inline-menu/blob/df8844c6a00444594f4e36a705c9a021d29fb558/source/send-menu.ts#L223-L232

Its similar to the generateSendMenuToChatFunction in its usage, first initialize the function and then use it for the given messageId.

Hope it helps!

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.