EdJoPaTo / grammy-inline-menu

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

Calculating button absolute path length in case with Cyrillic symbols #183

Closed harimambura closed 2 years ago

harimambura commented 2 years ago

Describe the bug Absolute path length calculating in "renderCallbackButtonTemplate" of "keyborad.js" does not consider that Cyrillic characters are 2 bytes in utf-8 encoding, so therefore it is not possible to understand that the length of the path fits the telegram api limit

To Reproduce Steps to reproduce the behavior: just make a callback button with path at example "очень длинный абсолютный путь больше 32 символов"

Expected behavior An error should be thrown

EdJoPaTo commented 2 years ago

Technically the error in this library is to provide something more readable than the Telegram API itself throws.

Do you have an idea on how to check the length of strings better? Want to provide a pull request there to improve it?

harimambura commented 2 years ago

With this error it's easier to debug which button is incorrect

Here my pull request