Upcoming [email protected] update — menu module
On the last day of August, let me make a lazy teaser for the upcoming aiogram-forms update. Meet the new module - the menu!
It's still under active development, so some APIs may change; however, the general idea stays the same.
As short and simple as possible: import, create the subclass we need, register it in the dispatcher.
from aiogram_forms.menus import Menu, MenuItem, actions
@dispatcher.register('main')
class MainMenu(Menu):
order_status = MenuItem('📫 Check order status', action=actions.ShowForm('order-status'))
settings = MenuItem('🔧 Settings', action=actions.ShowMenu('settings'))
about = MenuItem('ℹ️ About', action=actions.Custom(send_about_message))
@classmethod
async def title(cls) -> str:
return '🏠 Home'
@dispatcher.register('settings')
class SettingsMenu(Menu):
...
@dispatcher.register('order-status')
class CheckOrderStatusForm(Form):
...
@dp.message(Command('menu'))
async def command_menu_handler(message: types.Message, manager: Manager) -> None:
await manager.show('main')
As I indicated in the roadmap, the menu module will become available with version 1.2.0, which will presumably be released in September. In addition to the new module, updates include optimizations, fixes and a redesign of the manager.