EdJoPaTo / grammy-inline-menu

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

Whats the rule of setting menu ids, I get regex error with max stack exceeded #212

Closed snurfer0 closed 1 year ago

snurfer0 commented 1 year ago

I have this menu tree and when im adding main/prof-c-menu/... I get the following error

Menu Tree
menu                          main/
  menu                        main/reg-menu/
    menu                      main/reg-menu/reg-c-menu/
      action                  main/reg-menu/reg-c-menu/reg-ch-ac
      action                  main/reg-menu/reg-c-menu/reg-save-ac
    menu                      main/reg-menu/reg-d-menu/
      action                  main/reg-menu/reg-d-menu/start-ac
  menu                        main/prof-c-menu/
    action                    main/prof-c-menu/ul-wl-ac
    menu                      main/prof-c-menu/ch-menu/
      action                  main/prof-c-menu/ch-menu/up-add-ch
      action                  main/prof-c-menu/ch-menu/up-sel-ch-ac:(.+)
      action                  main/prof-c-menu/ch-menu/up-ed-ch-ac:(.+)

and this happens with lots of ids and I have to blindly guess what would work. any suggestions of what I should use and not as a menu id? cause I already make the ids short and not understandable just to fit the library id requirements. Also found that if I do not append -menu to the id I get the same regex error (to the ones that already have -menu)

d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/prof-d-menu\/reg-menu\/reg-c-menu\/reg-ch-ac$/: Maximum call stack size exceeded
    at new RegExp (<anonymous>)
EdJoPaTo commented 1 year ago

The regex looks like a circular dependency but the tree doesn't look like that… Does this happen on startup or while a button is pressed on runtime? Can you pinpoint the issue to a specific menu tree which causes the issue or provide a minimal example of it failing?

I already make the ids short and not understandable just to fit the library id requirements

Telegram Bot API states that the callback_data has a max length of 64. This is not something specific to this library, this is from the Telegram Bot API.