Skip to content

Commit

Permalink
feat: add both english and translated messages in magic filters
Browse files Browse the repository at this point in the history
  • Loading branch information
ZolotarevAlexandr committed Oct 29, 2024
1 parent 5326f52 commit 79c2039
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/bot/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
rules_confirmation_message = __("""I agree to and will abide by the stated rules.""")

create_booking_message = __("Create a booking")
create_booking_message_en = "Create a booking"
my_bookings_message = __("My bookings")
my_bookings_message_en = "My bookings"
image_schedule_message = __("Show the image with bookings")
image_schedule_message_en = "Show the image with bookings"

DIALOG_I18N_FORMAT_KEY = "dialog_i18n_format"
4 changes: 3 additions & 1 deletion src/bot/routers/booking/create_booking_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@


@router.message(any_state, Command("create_booking"))
@router.message(any_state, F.text == constants.create_booking_message)
@router.message(
any_state, (F.text == constants.create_booking_message) | (F.text == constants.create_booking_message_en)
)
async def start_booking(_message: Message, dialog_manager: DialogManager):
await dialog_manager.start(
CreateBookingStates.choose_date,
Expand Down
2 changes: 1 addition & 1 deletion src/bot/routers/booking/my_bookings_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


@router.message(any_state, Command("my_bookings"))
@router.message(any_state, F.text == constants.my_bookings_message)
@router.message(any_state, (F.text == constants.my_bookings_message) | (F.text == constants.my_bookings_message_en))
async def show_my_bookings(message: Message):
bookings = await api_client.get_user_bookings(message.from_user.id)
# only future bookings
Expand Down
4 changes: 3 additions & 1 deletion src/bot/routers/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def get_image_schedule_kb() -> types.InlineKeyboardMarkup:


@router.message(any_state, Command("image_schedule"))
@router.message(any_state, F.text == constants.image_schedule_message)
@router.message(
any_state, (F.text == constants.image_schedule_message) | (F.text == constants.image_schedule_message_en)
)
async def get_image_schedule(message: types.Message):
start_of_week = get_start_of_week()
image_bytes = await api_client.get_image_schedule(start_of_week)
Expand Down

0 comments on commit 79c2039

Please sign in to comment.