Add Pterodactyl cog #19
1 changed files with 1 additions and 6 deletions
|
@ -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-?]*[ -/]*[@-~])')
|
||||||
|
|
Loading…
Reference in a new issue