From df453d99a369b3a13c787f686afab2812f3e8a09 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Sat, 4 May 2024 20:01:37 +0100 Subject: [PATCH] Don't scream about unready bot on first boot --- src/main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 722dc81..452129b 100644 --- a/src/main.py +++ b/src/main.py @@ -30,12 +30,13 @@ class KumaThread(KillableThread): def __init__(self, url: str, interval: float = 60.0): super().__init__(target=self.run) self.daemon = True - self.log = logging.getLogger("philip.status") + self.log = logging.getLogger("jimmy .status") self.url = url self.interval = interval self.kill = Event() self.retries = 0 self.previous = False + self.was_ready = False def calculate_backoff(self) -> float: rnd = random.uniform(0, 1) @@ -55,8 +56,15 @@ class KumaThread(KillableThread): if url.endswith("ping="): url += str(round(bot.latency * 1000, 2)) if bot.is_ready() is False: + if self.was_ready is False: + # Wait rather than attack + self.log.warning("Waiting until bot is initially ready before sending status.") + time.sleep(1) + continue url = url.replace("status=up", "status=down") url = url.replace("msg=OK", "msg=Bot%20not%20ready") + else: + self.was_ready = True response = client.get(url) response.raise_for_status() self.previous = bot.is_ready()