Skip to content

Commit

Permalink
Fix tracking minecraft domain name timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
nfaltermeier committed Jan 13, 2023
1 parent bfb29a6 commit 8bfaaf3
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/minecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,22 @@ async def ping_minecraft():
for channel in channels:
await channel.send(message, delete_after=600)
except socket.timeout as timeout:
message = "Connection timed out (server offline)"
for channel in channels:
await channel.send(message, delete_after=600)
await print_timeout()
except OSError as oserror:
if oserror.errno == 113:
await print_timeout()
else:
await print_error()
except BaseException as error:
message = "An error occurred while pinging the server"
logging.exception(f'{datetime.now(timezone.utc)} minecraft ping failed')
for channel in channels:
await channel.send(message, delete_after=600)
await print_error()

async def print_timeout():
message = "Connection timed out (server offline)"
for channel in channels:
await channel.send(message, delete_after=600)

async def print_error():
message = "An error occurred while pinging the server"
logging.exception(f'{datetime.now(timezone.utc)} minecraft ping failed')
for channel in channels:
await channel.send(message, delete_after=600)

0 comments on commit 8bfaaf3

Please sign in to comment.