diff --git a/src/slack-bot/app.py b/src/slack-bot/app.py index 8992d62..e6f700f 100644 --- a/src/slack-bot/app.py +++ b/src/slack-bot/app.py @@ -97,6 +97,13 @@ def _is_active_shift_type(shift_type: str) -> bool: return determine_shift_type() == shift_type +def _shift_type_label(day_name: str, shift_type: str) -> str: + if day_name not in WEEKEND_DAYS: + return "" + label = "Day" if shift_type == "day" else "Night" + return f" ({label})" + + def _find_employee_shift(schedule, date_str, day_name, employee_ext): """Find which shift type an employee is assigned to on a given date. @@ -423,7 +430,11 @@ def create_app( if is_today(date_str) and _is_active_shift_type(shift_type): _update_3cx_routing(employee["extension"]) - respond(text=f"You picked up the shift for *{date.strftime('%A, %b %-d')}*.") + date_label = date.strftime("%A, %b %-d") + shift_label = _shift_type_label(day_name, shift_type) + respond( + text=f"You picked up the shift for *{date_label}*{shift_label}." + ) blocks = build_shift_change_message( user_id, @@ -484,8 +495,13 @@ def create_app( if is_today(date_str) and _is_active_shift_type(shift_type): _update_3cx_routing(FALLBACK_EXTENSION) + date_label = date.strftime("%A, %b %-d") + shift_label = _shift_type_label(day_name, shift_type) respond( - text=f"You dropped the shift for *{date.strftime('%A, %b %-d')}*. It's now open for pickup." + text=( + f"You dropped the shift for *{date_label}*{shift_label}. " + "It's now open for pickup." + ) ) blocks = build_shift_change_message( @@ -569,8 +585,13 @@ def create_app( target["name"], shift_type=shift_type, ) + date_label = date.strftime("%A, %b %-d") + shift_label = _shift_type_label(day_name, shift_type) respond( - text=f"Swapped *{date.strftime('%A, %b %-d')}* to {target['name']} (Ext {target['extension']})." + text=( + f"Swapped *{date_label}*{shift_label} to {target['name']} " + f"(Ext {target['extension']})." + ) ) try: