From d1aaea17f7dad09b0523d8e98647927f103ebb83 Mon Sep 17 00:00:00 2001 From: bMorgan01 Date: Sun, 20 Nov 2022 11:21:46 -0700 Subject: [PATCH] safety --- mstbot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mstbot.py b/mstbot.py index 65fb5cf..6917523 100644 --- a/mstbot.py +++ b/mstbot.py @@ -502,10 +502,12 @@ async def status_task(sid: int): except asyncio.exceptions.TimeoutError: print(currServ.name, "Timeout, server lagging?") players = -1 + lastSeconds = -1 except (ConnectionRefusedError, socket.gaierror): print(currServ.name, "Cannot connect to server, down?") players = -1 + lastSeconds = -1 iChannels = find_channels(serv=currServ, channame="IP: ", channamesearch="in", chantype=ChannelType.voice) pChannels = find_channels(serv=currServ, channame="Players: ", channamesearch="in", @@ -557,7 +559,7 @@ async def status_task(sid: int): await currServ.create_voice_channel("Players: " + str(players) + "/" + str(max), overwrites=overwrites) - if getShowHours(sid, cursor) and not first_iter and lastSeconds is not None: + if getShowHours(sid, cursor) and not first_iter and lastSeconds != -1: tStr = "Player Hrs: " + str(round((lastSeconds + len(names) * (currTime - lastTime).total_seconds())/3600)) if len(tChannels) > 0: lastTName = tChannels[0].name