feat(pterodactyl): added a discord invite placeholder

updated default chat command as well, and also a configuration value and related command
This commit is contained in:
Seaswimmer 2024-03-04 22:59:43 -05:00
parent 87dfc03812
commit 34c34e745a
Signed by untrusted user: cswimr
GPG key ID: B8953EC01E5C4063
3 changed files with 17 additions and 1 deletions

View file

@ -62,6 +62,12 @@ This is to prevent the console channel from flooding and getting backed up by Di
Default value: `None` Default value: `None`
## `invite`
This option determines what url the chat command will substitute in for the Discord invite placeholder.
Default value: `None`
## `ip` ## `ip`
This option determines whether or not IP's will be redacted when posted in chat or to the console channel. This option determines whether or not IP's will be redacted when posted in chat or to the console channel.

View file

@ -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$", 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$", 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) \[(.*)\]$", 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", api_endpoint="minecraft",
chat_channel=None, chat_channel=None,
startup_msg='Server started!', startup_msg='Server started!',
@ -21,5 +21,6 @@ def register_config(config_obj: Config) -> None:
join_msg='Welcome to the server! 👋', join_msg='Welcome to the server! 👋',
leave_msg='Goodbye! 👋', leave_msg='Goodbye! 👋',
mask_ip=True, mask_ip=True,
invite=None,
regex_blacklist={}, regex_blacklist={},
) )

View file

@ -91,6 +91,7 @@ class Pterodactyl(commands.Cog):
"M": message.content.replace('"',''), "M": message.content.replace('"',''),
"N": message.author.display_name, "N": message.author.display_name,
"U": message.author.name, "U": message.author.name,
"V": await config.invite() or "use [p]pterodactyl config invite to change me",
} }
for key, value in placeholders.items(): for key, value in placeholders.items():
command = command.replace('.$' + key, value) command = command.replace('.$' + key, value)
@ -181,6 +182,12 @@ class Pterodactyl(commands.Cog):
await config.console_channel.set(channel.id) await config.console_channel.set(channel.id)
await ctx.send(f"Console channel set to {channel.mention}") 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") @pterodactyl_config.group(name = "chat")
async def pterodactyl_config_chat(self, ctx: commands.Context): async def pterodactyl_config_chat(self, ctx: commands.Context):
"""Configure chat settings.""" """Configure chat settings."""
@ -345,6 +352,7 @@ class Pterodactyl(commands.Cog):
leave_msg = await config.leave_msg() leave_msg = await config.leave_msg()
mask_ip = await config.mask_ip() mask_ip = await config.mask_ip()
api_endpoint = await config.api_endpoint() api_endpoint = await config.api_endpoint()
invite = await config.invite()
regex_blacklist: dict = await config.regex_blacklist() regex_blacklist: dict = await config.regex_blacklist()
embed = discord.Embed(color = await ctx.embed_color(), title="Pterodactyl Configuration") embed = discord.Embed(color = await ctx.embed_color(), title="Pterodactyl Configuration")
embed.description = f"""**Base URL:** {base_url} embed.description = f"""**Base URL:** {base_url}
@ -357,6 +365,7 @@ class Pterodactyl(commands.Cog):
**Leave Message:** {leave_msg} **Leave Message:** {leave_msg}
**Mask IP:** {self.get_bool_str(mask_ip)} **Mask IP:** {self.get_bool_str(mask_ip)}
**API Endpoint:** `{api_endpoint}` **API Endpoint:** `{api_endpoint}`
**Invite:** {invite}
**Chat Command:** {box(chat_command, 'json')} **Chat Command:** {box(chat_command, 'json')}
**Chat Regex:** {box(chat_regex, 're')} **Chat Regex:** {box(chat_regex, 're')}