From 6e6559d80cdf2b0c100157919a46fd91b7a963c3 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Wed, 28 Feb 2024 08:10:46 -0500 Subject: [PATCH] feat(pterodactyl): added more verbose debug logging to establish_websocket_connection --- pterodactyl/pterodactyl.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pterodactyl/pterodactyl.py b/pterodactyl/pterodactyl.py index aa819a7..c279715 100644 --- a/pterodactyl/pterodactyl.py +++ b/pterodactyl/pterodactyl.py @@ -29,6 +29,7 @@ class Pterodactyl(commands.Cog): try: client = PterodactylClient(base_url, api_key).client websocket_credentials = client.servers.get_websocket(server_id) + self.logger.debug("Websocket connection details retrieved: " + websocket_credentials) except exceptions.ClientConfigError as e: self.logger.error(f'Failed to initialize Pterodactyl client: {e}') return @@ -49,9 +50,14 @@ class Pterodactyl(commands.Cog): while True: message = await websocket.recv() - if json.loads(message)['event'] == 'token expiring': + if json.loads(message)['event'] in ['token expiring', 'token expired']: + self.logger.debug("Received token expiring/expired event. Refreshing token.") websocket_credentials = client.servers.get_websocket(server_id) auth_message = json.dumps({"event": "auth", "args": [websocket_credentials['data']['token']]}) + await websocket.send(auth_message) + self.logger.debug("Authentication message sent") + if json.loads(message)['event'] == 'auth success': + self.logger.debug("Authentication successful") self.logger.debug("Received message: %s", message) async def cog_load(self):