fix(pterodactyl): remove looping functionality from websocket.connect on line 62 as it's irrelevant now and was broken regardless

This commit is contained in:
Seaswimmer 2024-02-29 22:07:22 -05:00
parent 9e15730af9
commit 839ead56eb
Signed by: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -59,8 +59,7 @@ class Pterodactyl(commands.Cog):
except exceptions.PterodactylApiError as e: except exceptions.PterodactylApiError as e:
return self.logger.error('Failed to retrieve Pterodactyl websocket: %s', e) return self.logger.error('Failed to retrieve Pterodactyl websocket: %s', e)
async for websocket in websockets.connect(websocket_credentials['data']['socket'], origin=base_url, ping_timeout=60): async with websockets.connect(websocket_credentials['data']['socket'], origin=base_url, ping_timeout=60) as websocket:
try:
self.logger.info("WebSocket connection established") self.logger.info("WebSocket connection established")
auth_message = json.dumps({"event": "auth", "args": [websocket_credentials['data']['token']]}) auth_message = json.dumps({"event": "auth", "args": [websocket_credentials['data']['token']]})
@ -107,10 +106,6 @@ class Pterodactyl(commands.Cog):
console = self.bot.get_channel(await self.config.console_channel()) console = self.bot.get_channel(await self.config.console_channel())
if console is not None: if console is not None:
await console.send(f"Server status changed! `{json.loads(message)['args'][0]}`") await console.send(f"Server status changed! `{json.loads(message)['args'][0]}`")
except (websockets.exceptions.ConnectionClosed) as e:
self.logger.info("WebSocket connection closed: %s", e)
websocket_credentials = client.servers.get_websocket(server_id)
continue
def remove_ansi_escape_codes(self, text: str) -> str: def remove_ansi_escape_codes(self, text: str) -> str:
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')