Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes several changes to improve the text formatting and menu handling in the bot's role-specific modules. The most important changes involve refactoring text generation into a new method, updating menu-building methods to be more flexible, and centralizing text constants in a localization file.
Refactoring and Text Formatting:
bot/roles/barman.py
: Introduced a new method__pre_complete_order_text
to generate order text, which is now used in__handle_pre_complete_order
and__handle_complete_order
methods. This change reduces code duplication and centralizes text formatting logic. [1] [2]Menu Handling Improvements:
bot/roles/customer.py
: Updated the method__build_show_products_menu
to__build_products_menu
to accept a prefix parameter, making it more flexible for different contexts. This change is reflected in multiple methods that build menus for product-related actions. [1] [2] [3]Centralized Text Constants:
res/locales/ru.toml
: Added new text constants for various order and product-related messages, which are now used throughout the code to ensure consistency and ease of localization.Minor Adjustments and Fixes:
bot/roles/customer.py
: Removed unused callback prefixes and updated error handling text to use a localized string. [1] [2]tests/test_handlers/test_help_handler.py
: Reformatted thetelegram_user
initialization for better readability.