From e7a839c6cda02d57422a4a12b6ce99e84fceb58a Mon Sep 17 00:00:00 2001 From: ZeldaZach Date: Sun, 21 Jul 2024 00:16:18 +0200 Subject: [PATCH] Remove need to download twice on startup --- zulip_bots/zulip_bots/schedulebot.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/zulip_bots/zulip_bots/schedulebot.py b/zulip_bots/zulip_bots/schedulebot.py index 1f4fb85..e09eb3e 100644 --- a/zulip_bots/zulip_bots/schedulebot.py +++ b/zulip_bots/zulip_bots/schedulebot.py @@ -279,24 +279,27 @@ def main(conf_file, hour=-1, no_groups=False, stream="General", no_mentions=Fals start_time = start_time[:-1] start_time = timegm(time.strptime(start_time, "%Y-%m-%dT%H:%M:%S")) - # Attempt to download the schedule - schedule = reload_schedule() - if schedule is None: - raise Exception("Schedule failed to download") - if hour >= 0: + # Attempt to download the schedule + schedule = reload_schedule() + if schedule is None: + raise Exception("Schedule failed to download") + if not no_groups: update_groups(client, group_ids, groups_by_shift, schedule, hour, start_time, last) if stream: post_schedule(client, send_client, start_time, schedule, stream, hour, no_mentions, last, omega) return + schedule = None while True: hour = int((time.time() - start_time) / 3600) # Download a new schedule or use the old one if there's a failure new_schedule = reload_schedule() if new_schedule is not None: schedule = new_schedule + if schedule is None: + raise Exception("Schedule failed to download") if not no_initial: if not no_groups: