From f6859cd7484ceee3ba1e3f2c1434eff03395dead Mon Sep 17 00:00:00 2001 From: dymik739 Date: Sat, 10 Feb 2024 18:37:54 +0200 Subject: [PATCH] auto-schedule-pro-v2: update for term 4 and add support for alternative commands --- modules/auto-schedule-pro-v2/main.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/auto-schedule-pro-v2/main.py b/modules/auto-schedule-pro-v2/main.py index 502377d..50298e5 100644 --- a/modules/auto-schedule-pro-v2/main.py +++ b/modules/auto-schedule-pro-v2/main.py @@ -290,7 +290,8 @@ def process(message, path): # one printable symbol, so this is already protected base_command = full_command[0].lower() - if base_command not in ["!пара", "!пари", "!schedule-ctl"]: + if base_command not in ["!пара", "!пари", "!schedule-ctl", + "!para", "!pary"]: return None, None global module_path @@ -309,16 +310,20 @@ def process(message, path): reference_time = int(current_time.strftime("%s")) - current_seconds - if base_command == "!пара": + if base_command in ["!пара", "!para"]: # easter egg - study_begin_ts = int(datetime(year=2023, month=9, day=4).strftime("%s")) + study_begin_ts = int(datetime(year=2024, month=2, day=5).strftime("%s")) current_ts = int(datetime.now().strftime("%s")) - if -3600*4 < study_begin_ts - current_ts < 0: + until_study_day = study_begin_ts - current_ts + + if -3600*4 < until_study_day < 0: return "Навчання от-от розпочнеться!", None - elif 0 <= study_begin_ts - current_ts < 1209600: - return f"До навчання залишилося {study_begin_ts - current_ts} секунд...", None - elif study_begin_ts - current_ts >= 1209600: + elif 0 <= until_study_day < 3600*24*14: + return f"До навчання залишилося {until_study_day} секунд..." \ + f" ({round(until_study_day/3600, 4)} годин," \ + f" {round(until_study_day/3600/24, 4)} діб)", None + elif until_study_day >= 3600*24*14: return "Ви маєте законне право відпочити, пари почнуться не скоро", None # actual lesson finding code @@ -358,7 +363,7 @@ def process(message, path): return get_lesson_description(schedule, reference_time, closest_lesson_time, current_day, current_week, custom_name_prefix="Актуальна пара", template=output_style_preference), "HTML" - elif base_command == "!пари": + elif base_command in ["!пари", "!pary"]: base_day = current_week * 7 + current_day if len(full_command) >= 2: