Add Pterodactyl cog #19

Merged
cswimr merged 139 commits from pterodactyl into main 2024-03-02 00:07:42 -05:00
Showing only changes of commit 50dd5c64b4 - Show all commits

View file

@ -177,7 +177,12 @@ class Pterodactyl(commands.Cog):
if message.channel.id == await self.config.console_channel() and not message.author.bot: if message.channel.id == await self.config.console_channel() and not message.author.bot:
self.logger.debug("Received console command from %s: %s", message.author.id, message.content) self.logger.debug("Received console command from %s: %s", message.author.id, message.content)
await message.channel.send(f"Received console command from {message.author.id}: {message.content[:1900]}") await message.channel.send(f"Received console command from {message.author.id}: {message.content[:1900]}")
await self.websocket.send(json.dumps({"event": "send command", "args": [message.content]})) try:
await self.websocket.send(json.dumps({"event": "send command", "args": [message.content]}))
except websockets.exceptions.ConnectionClosed as e:
self.logger.error("WebSocket connection closed: %s", e)
self.task.cancel()
self.task = self.get_task()
if message.channel.id == await self.config.chat_channel() and not message.author.bot: if message.channel.id == await self.config.chat_channel() and not message.author.bot:
self.logger.debug("Received chat message from %s: %s", message.author.id, message.content) self.logger.debug("Received chat message from %s: %s", message.author.id, message.content)
channel = self.bot.get_channel(await self.config.console_channel()) channel = self.bot.get_channel(await self.config.console_channel())
@ -185,7 +190,12 @@ class Pterodactyl(commands.Cog):
await channel.send(f"Received chat message from {message.author.id}: {message.content[:1900]}") await channel.send(f"Received chat message from {message.author.id}: {message.content[:1900]}")
msg = json.dumps({"event": "send command", "args": [await self.get_tellraw_string(message.author.display_name, message.content, message.author.color)]}) msg = json.dumps({"event": "send command", "args": [await self.get_tellraw_string(message.author.display_name, message.content, message.author.color)]})
self.logger.debug("Sending chat message to server:\n%s", msg) self.logger.debug("Sending chat message to server:\n%s", msg)
await self.websocket.send(msg) try:
await self.websocket.send(msg)
except websockets.exceptions.ConnectionClosed as e:
self.logger.error("WebSocket connection closed: %s", e)
self.task.cancel()
self.task = self.get_task()
@commands.group(autohelp = True, name = "pterodactyl", aliases = ["ptero"]) @commands.group(autohelp = True, name = "pterodactyl", aliases = ["ptero"])
async def pterodactyl(self, ctx: commands.Context): async def pterodactyl(self, ctx: commands.Context):