fix(pterodactyl): update pterodactyl for the new version of websockets & fix a few minor bugs
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 42s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 47s

This commit is contained in:
cswimr 2025-01-26 15:04:05 +00:00
parent d51e3f17e9
commit ff9e20be91
Signed by: cswimr
GPG key ID: 0EC431A8DA8F8087
3 changed files with 66 additions and 50 deletions

View file

@ -22,14 +22,14 @@ class Pterodactyl(commands.Cog):
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
__version__ = "2.0.4"
__version__ = "2.0.5"
__documentation__ = "https://seacogs.coastalcommits.com/pterodactyl/"
def __init__(self, bot: Red):
self.bot = bot
self.client: Optional[PterodactylClient] = None
self.task: Optional[asyncio.Task] = None
self.websocket: Optional[websockets.WebSocketClientProtocol] = None
self.websocket: Optional[websockets.ClientConnection] = None
self.retry_counter: int = 0
register_config(config)
self.task = self.get_task()
@ -51,15 +51,18 @@ class Pterodactyl(commands.Cog):
api_key = pterodactyl_keys.get("api_key")
if api_key is None:
self.task.cancel()
raise ValueError("Pterodactyl API key not set. Please set it using `[p]set api`.")
logger.error("Pterodactyl API key not set. Please set it using `[p]set api`.")
return
base_url = await config.base_url()
if base_url is None:
self.task.cancel()
raise ValueError("Pterodactyl base URL not set. Please set it using `[p]pterodactyl config url`.")
logger.error("Pterodactyl base URL not set. Please set it using `[p]pterodactyl config url`.")
return
server_id = await config.server_id()
if server_id is None:
self.task.cancel()
raise ValueError("Pterodactyl server ID not set. Please set it using `[p]pterodactyl config serverid`.")
logger.error("Pterodactyl server ID not set. Please set it using `[p]pterodactyl config serverid`.")
return
self.client = PterodactylClient(base_url, api_key).client
@ -67,7 +70,6 @@ class Pterodactyl(commands.Cog):
self.update_topic.cancel()
self.task.cancel()
self.retry_counter = 0
await self.client._session.close() # pylint: disable=protected-access # noqa: SLF001
def get_task(self) -> asyncio.Task:
from pterodactyl.websocket import establish_websocket_connection
@ -76,7 +78,7 @@ class Pterodactyl(commands.Cog):
task.add_done_callback(self.error_callback)
return task
def error_callback(self, fut) -> None: # NOTE - Thanks flame442 and zephyrkul for helping me figure this out
def error_callback(self, fut) -> None: # NOTE Thanks flame442 and zephyrkul for helping me figure this out
try:
fut.result()
except asyncio.CancelledError: