Don't scream about unready bot on first boot
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 9s
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 9s
This commit is contained in:
parent
d977860cde
commit
df453d99a3
1 changed files with 9 additions and 1 deletions
10
src/main.py
10
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()
|
||||
|
|
Loading…
Reference in a new issue