From 34c34e745a4a61197ea04b2bec005352faef3580 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Mon, 4 Mar 2024 22:59:43 -0500 Subject: [PATCH] feat(pterodactyl): added a discord invite placeholder updated default chat command as well, and also a configuration value and related command --- .docs/pterodactyl/configuration.md | 6 ++++++ pterodactyl/config.py | 3 ++- pterodactyl/pterodactyl.py | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.docs/pterodactyl/configuration.md b/.docs/pterodactyl/configuration.md index e37698f..ecf4982 100644 --- a/.docs/pterodactyl/configuration.md +++ b/.docs/pterodactyl/configuration.md @@ -62,6 +62,12 @@ This is to prevent the console channel from flooding and getting backed up by Di Default value: `None` +## `invite` + +This option determines what url the chat command will substitute in for the Discord invite placeholder. + +Default value: `None` + ## `ip` This option determines whether or not IP's will be redacted when posted in chat or to the console channel. diff --git a/pterodactyl/config.py b/pterodactyl/config.py index a8ad138..770c631 100644 --- a/pterodactyl/config.py +++ b/pterodactyl/config.py @@ -13,7 +13,7 @@ def register_config(config_obj: Config) -> None: join_regex=r"^\[\d{2}:\d{2}:\d{2} INFO\]: ([^<\n]+) joined the game$", leave_regex=r"^\[\d{2}:\d{2}:\d{2} INFO\]: ([^<\n]+) left the game$", achievement_regex=r"^\[\d{2}:\d{2}:\d{2} INFO\]: (.*) has (made the advancement|completed the challenge) \[(.*)\]$", - chat_command='tellraw @a ["",{"text":".$N ","color":".$C"},{"text":" (DISCORD): ","color":"blue"},{"text":".$M","color":"white"}]', + chat_command='tellraw @a ["",{"text":".$N ","color":".$C","insertion":"<@.$I>","hoverEvent":{"action":"show_text","contents":"Shift click to mention this user inside Discord"}},{"text":"(DISCORD):","color":"blue","clickEvent":{"action":"open_url","value":".$V"},"hoverEvent":{"action":"show_text","contents":"Click to join the Discord Server"}},{"text":" .$M","color":"white"}]', # noqa: E501 api_endpoint="minecraft", chat_channel=None, startup_msg='Server started!', @@ -21,5 +21,6 @@ def register_config(config_obj: Config) -> None: join_msg='Welcome to the server! 👋', leave_msg='Goodbye! 👋', mask_ip=True, + invite=None, regex_blacklist={}, ) diff --git a/pterodactyl/pterodactyl.py b/pterodactyl/pterodactyl.py index de017f4..212cbd2 100644 --- a/pterodactyl/pterodactyl.py +++ b/pterodactyl/pterodactyl.py @@ -91,6 +91,7 @@ class Pterodactyl(commands.Cog): "M": message.content.replace('"',''), "N": message.author.display_name, "U": message.author.name, + "V": await config.invite() or "use [p]pterodactyl config invite to change me", } for key, value in placeholders.items(): command = command.replace('.$' + key, value) @@ -181,6 +182,12 @@ class Pterodactyl(commands.Cog): await config.console_channel.set(channel.id) await ctx.send(f"Console channel set to {channel.mention}") + @pterodactyl_config.command(name = "invite") + async def pterodactyl_config_invite(self, ctx: commands.Context, invite: str) -> None: + """Set the invite link for your server.""" + await config.invite.set(invite) + await ctx.send(f"Invite link set to {invite}") + @pterodactyl_config.group(name = "chat") async def pterodactyl_config_chat(self, ctx: commands.Context): """Configure chat settings.""" @@ -345,6 +352,7 @@ class Pterodactyl(commands.Cog): leave_msg = await config.leave_msg() mask_ip = await config.mask_ip() api_endpoint = await config.api_endpoint() + invite = await config.invite() regex_blacklist: dict = await config.regex_blacklist() embed = discord.Embed(color = await ctx.embed_color(), title="Pterodactyl Configuration") embed.description = f"""**Base URL:** {base_url} @@ -357,6 +365,7 @@ class Pterodactyl(commands.Cog): **Leave Message:** {leave_msg} **Mask IP:** {self.get_bool_str(mask_ip)} **API Endpoint:** `{api_endpoint}` + **Invite:** {invite} **Chat Command:** {box(chat_command, 'json')} **Chat Regex:** {box(chat_regex, 're')}