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 9e8bcb952a - Show all commits

View file

@ -152,14 +152,11 @@ class Pterodactyl(commands.Cog):
"""Configure Pterodactyl settings.""" """Configure Pterodactyl settings."""
@pterodactyl_config.command(name = "url") @pterodactyl_config.command(name = "url")
async def pterodactyl_config_base_url(self, ctx: commands.Context, *, base_url: str = None) -> None: async def pterodactyl_config_base_url(self, ctx: commands.Context, *, base_url: str) -> None:
"""Set the base URL of your Pterodactyl Panel. """Set the base URL of your Pterodactyl Panel.
Please include the protocol (http/https). Please include the protocol (http/https).
Example: `https://panel.example.com`""" Example: `https://panel.example.com`"""
if base_url is None:
base_url = await config.base_url()
return await ctx.send(f"Base URL is currently set to {base_url}")
await config.base_url.set(base_url) await config.base_url.set(base_url)
await ctx.send(f"Base URL set to {base_url}") await ctx.send(f"Base URL set to {base_url}")
logger.info("Configuration value set: base_url = %s\nRestarting task...", base_url) logger.info("Configuration value set: base_url = %s\nRestarting task...", base_url)
@ -194,14 +191,11 @@ class Pterodactyl(commands.Cog):
await ctx.send(f"Chat channel set to {channel.mention}") await ctx.send(f"Chat channel set to {channel.mention}")
@pterodactyl_config_chat.command(name = "command") @pterodactyl_config_chat.command(name = "command")
async def pterodactyl_config_chat_command(self, ctx: commands.Context, *, command: str = None) -> None: async def pterodactyl_config_chat_command(self, ctx: commands.Context, *, command: str) -> None:
"""Set the command that will be used to send messages from Discord. """Set the command that will be used to send messages from Discord.
Required placeholders: `.$U` (username), `.$M` (message), `.$C` (color) Required placeholders: `.$U` (username), `.$M` (message), `.$C` (color)
See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#changing-the-tellraw-command) for more information.""" See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#changing-the-tellraw-command) for more information."""
if command is None:
command = await config.chat_command()
return await ctx.send(f"Chat command is currently set to:\n{box(command, 'json')}")
await config.chat_command.set(command) await config.chat_command.set(command)
await ctx.send(f"Chat command set to:\n{box(command, 'json')}") await ctx.send(f"Chat command set to:\n{box(command, 'json')}")
@ -210,57 +204,42 @@ class Pterodactyl(commands.Cog):
"""Set regex patterns.""" """Set regex patterns."""
@pterodactyl_config_regex.command(name = "chat") @pterodactyl_config_regex.command(name = "chat")
async def pterodactyl_config_regex_chat(self, ctx: commands.Context, *, regex: str = None) -> None: async def pterodactyl_config_regex_chat(self, ctx: commands.Context, *, regex: str) -> None:
"""Set the regex pattern to match chat messages on the server. """Set the regex pattern to match chat messages on the server.
See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#my-chat-messages-arent-detected) for more information.""" See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#my-chat-messages-arent-detected) for more information."""
if regex is None:
regex = await config.chat_regex()
return await ctx.send(f"Chat regex is currently set to:\n{box(regex, 'regex')}")
await config.chat_regex.set(regex) await config.chat_regex.set(regex)
await ctx.send(f"Chat regex set to:\n{box(regex, 'regex')}") await ctx.send(f"Chat regex set to:\n{box(regex, 'regex')}")
@pterodactyl_config_regex.command(name = "server") @pterodactyl_config_regex.command(name = "server")
async def pterodactyl_config_regex_server(self, ctx: commands.Context, *, regex: str = None) -> None: async def pterodactyl_config_regex_server(self, ctx: commands.Context, *, regex: str) -> None:
"""Set the regex pattern to match server messages on the server. """Set the regex pattern to match server messages on the server.
See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#my-chat-messages-arent-detected) for more information.""" See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#my-chat-messages-arent-detected) for more information."""
if regex is None:
regex = await config.server_regex()
return await ctx.send(f"Server regex is currently set to:\n{box(regex, 'regex')}")
await config.server_regex.set(regex) await config.server_regex.set(regex)
await ctx.send(f"Server regex set to:\n{box(regex, 'regex')}") await ctx.send(f"Server regex set to:\n{box(regex, 'regex')}")
@pterodactyl_config_regex.command(name = "join") @pterodactyl_config_regex.command(name = "join")
async def pterodactyl_config_regex_join(self, ctx: commands.Context, *, regex: str = None) -> None: async def pterodactyl_config_regex_join(self, ctx: commands.Context, *, regex: str) -> None:
"""Set the regex pattern to match join messages on the server. """Set the regex pattern to match join messages on the server.
See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#my-chat-messages-arent-detected) for more information.""" See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#my-chat-messages-arent-detected) for more information."""
if regex is None:
regex = await config.join_regex()
return await ctx.send(f"Join regex is currently set to:\n{box(regex, 'regex')}")
await config.join_regex.set(regex) await config.join_regex.set(regex)
await ctx.send(f"Join regex set to:\n{box(regex, 'regex')}") await ctx.send(f"Join regex set to:\n{box(regex, 'regex')}")
@pterodactyl_config_regex.command(name = "leave") @pterodactyl_config_regex.command(name = "leave")
async def pterodactyl_config_regex_leave(self, ctx: commands.Context, *, regex: str = None) -> None: async def pterodactyl_config_regex_leave(self, ctx: commands.Context, *, regex: str) -> None:
"""Set the regex pattern to match leave messages on the server. """Set the regex pattern to match leave messages on the server.
See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#my-chat-messages-arent-detected) for more information.""" See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#my-chat-messages-arent-detected) for more information."""
if regex is None:
regex = await config.leave_regex()
return await ctx.send(f"Leave regex is currently set to:\n{box(regex, 'regex')}")
await config.leave_regex.set(regex) await config.leave_regex.set(regex)
await ctx.send(f"Leave regex set to:\n{box(regex, 'regex')}") await ctx.send(f"Leave regex set to:\n{box(regex, 'regex')}")
@pterodactyl_config_regex.command(name = "achievement") @pterodactyl_config_regex.command(name = "achievement")
async def pterodactyl_config_regex_achievement(self, ctx: commands.Context, *, regex: str = None) -> None: async def pterodactyl_config_regex_achievement(self, ctx: commands.Context, *, regex: str) -> None:
"""Set the regex pattern to match achievement messages on the server. """Set the regex pattern to match achievement messages on the server.
See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#my-chat-messages-arent-detected) for more information.""" See [documentation](https://seacogs.coastalcommits.com/pterodactyl/setup/#my-chat-messages-arent-detected) for more information."""
if regex is None:
regex = await config.achievement_regex()
return await ctx.send(f"Achievement regex is currently set to:\n{box(regex, 'regex')}")
await config.achievement_regex.set(regex) await config.achievement_regex.set(regex)
await ctx.send(f"Achievement regex set to:\n{box(regex, 'regex')}") await ctx.send(f"Achievement regex set to:\n{box(regex, 'regex')}")
@ -269,58 +248,40 @@ class Pterodactyl(commands.Cog):
"""Configure message settings.""" """Configure message settings."""
@pterodactyl_config_messages.command(name = "startup") @pterodactyl_config_messages.command(name = "startup")
async def pterodactyl_config_messages_startup(self, ctx: commands.Context, *, message: str = None) -> None: async def pterodactyl_config_messages_startup(self, ctx: commands.Context, *, message: str) -> None:
"""Set the message that will be sent when the server starts.""" """Set the message that will be sent when the server starts."""
if message is None:
message = await config.startup_msg()
return await ctx.send(f"Startup message is currently set to: {message}")
await config.startup_msg.set(message) await config.startup_msg.set(message)
await ctx.send(f"Startup message set to: {message}") await ctx.send(f"Startup message set to: {message}")
@pterodactyl_config_messages.command(name = "shutdown") @pterodactyl_config_messages.command(name = "shutdown")
async def pterodactyl_config_messages_shutdown(self, ctx: commands.Context, *, message: str = None) -> None: async def pterodactyl_config_messages_shutdown(self, ctx: commands.Context, *, message: str) -> None:
"""Set the message that will be sent when the server stops.""" """Set the message that will be sent when the server stops."""
if message is None:
message = await config.shutdown_msg()
return await ctx.send(f"Shutdown message is currently set to: {message}")
await config.shutdown_msg.set(message) await config.shutdown_msg.set(message)
await ctx.send(f"Shutdown message set to: {message}") await ctx.send(f"Shutdown message set to: {message}")
@pterodactyl_config_messages.command(name = "join") @pterodactyl_config_messages.command(name = "join")
async def pterodactyl_config_messages_join(self, ctx: commands.Context, *, message: str = None) -> None: async def pterodactyl_config_messages_join(self, ctx: commands.Context, *, message: str) -> None:
"""Set the message that will be sent when a user joins the server. This is only shown in embeds.""" """Set the message that will be sent when a user joins the server. This is only shown in embeds."""
if message is None:
message = await config.join_msg()
return await ctx.send(f"Join message is currently set to: {message}")
await config.join_msg.set(message) await config.join_msg.set(message)
await ctx.send(f"Join message set to: {message}") await ctx.send(f"Join message set to: {message}")
@pterodactyl_config_messages.command(name = "leave") @pterodactyl_config_messages.command(name = "leave")
async def pterodactyl_config_messages_leave(self, ctx: commands.Context, *, message: str = None) -> None: async def pterodactyl_config_messages_leave(self, ctx: commands.Context, *, message: str) -> None:
"""Set the message that will be sent when a user leaves the server. This is only shown in embeds.""" """Set the message that will be sent when a user leaves the server. This is only shown in embeds."""
if message is None:
message = await config.leave_msg()
return await ctx.send(f"Leave message is currently set to: {message}")
await config.leave_msg.set(message) await config.leave_msg.set(message)
await ctx.send(f"Leave message set to: {message}") await ctx.send(f"Leave message set to: {message}")
@pterodactyl_config.command(name = "ip") @pterodactyl_config.command(name = "ip")
async def pterodactyl_config_mask_ip(self, ctx: commands.Context, mask: bool = None) -> None: async def pterodactyl_config_mask_ip(self, ctx: commands.Context, mask: bool) -> None:
"""Mask the IP addresses of users in console messages.""" """Mask the IP addresses of users in console messages."""
if mask is None:
mask = await config.mask_ip()
return await ctx.send(f"IP masking is currently set to {mask}")
await config.mask_ip.set(mask) await config.mask_ip.set(mask)
await ctx.send(f"IP masking set to {mask}") await ctx.send(f"IP masking set to {mask}")
@pterodactyl_config.command(name = "api") @pterodactyl_config.command(name = "api")
async def pterodactyl_config_api(self, ctx: commands.Context, endpoint: str = None) -> None: async def pterodactyl_config_api(self, ctx: commands.Context, endpoint: str) -> None:
"""Set the API endpoint to use for the user retrival API. """Set the API endpoint to use for the user retrival API.
This is only used for retrieving user avatars for webhook messages.""" This is only used for retrieving user avatars for webhook messages."""
if endpoint is None:
endpoint = await config.api_endpoint()
return await ctx.send(f"API endpoint is currently set to {endpoint}")
await config.api_endpoint.set(endpoint) await config.api_endpoint.set(endpoint)
await ctx.send(f"API endpoint set to {endpoint}") await ctx.send(f"API endpoint set to {endpoint}")