auto-schedule-pro-v2: update for term 4 and add support for alternative commands

This commit is contained in:
dymik739 2024-02-10 18:37:54 +02:00
parent b546d2c8d2
commit f6859cd748
1 changed files with 13 additions and 8 deletions

View File

@ -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: