Add Pterodactyl cog #19
1 changed files with 12 additions and 2 deletions
|
@ -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]}")
|
||||||
|
try:
|
||||||
await self.websocket.send(json.dumps({"event": "send command", "args": [message.content]}))
|
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)
|
||||||
|
try:
|
||||||
await self.websocket.send(msg)
|
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):
|
||||||
|
|
Loading…
Reference in a new issue