fluentogram icon indicating copy to clipboard operation
fluentogram copied to clipboard

Lost i18n while handling UnknowIntent using aiogram-dialog

Open molchanov-vs opened this issue 11 months ago • 1 comments

While handling UnknownIntent Error i18n can't be found middleware_data.

@start_router.errors(ExceptionTypeFilter(UnknownIntent))
async def on_unknown_intent(event: ErrorEvent, dialog_manager: DialogManager):
    """Example of handling UnknownIntent Error and starting new dialog."""
    logging.error("UnknownIntent Error. Restarting dialog: %s", event.exception)

    print(dialog_manager.middleware_data.keys())
    # dict_keys(['dispatcher', 'bots', '_translator_hub', 'bot', 'event_from_user', 'event_chat', 'fsm_storage', 'state', 'raw_state', 'dialog_bg_factory', 'event_router', 'handler', 'aiogd_storage_proxy', 'aiogd_stack', 'aiogd_context', 'dialog_manager'])

    await dialog_manager.start(Main.MAIN, mode=StartMode.RESET_STACK)

In next dialog with state Main.Main

TypeError: dialog_get_data() missing 1 required positional argument: 'i18n'

async def dialog_get_data(i18n: TranslatorRunner, dialog_manager: DialogManager, **kwargs):

molchanov-vs avatar Mar 26 '24 03:03 molchanov-vs