diff --git a/jarvis/__init__.py b/jarvis/__init__.py index 163408c..fe0d348 100644 --- a/jarvis/__init__.py +++ b/jarvis/__init__.py @@ -41,7 +41,7 @@ jarvis = commands.Bot( slash = SlashCommand(jarvis, sync_commands=False, sync_on_cog_reload=True) jarvis_self = Process() -__version__ = "1.11.0" +__version__ = "1.11.1" @jarvis.event diff --git a/jarvis/cogs/dev.py b/jarvis/cogs/dev.py index 08bafa9..4345c0c 100644 --- a/jarvis/cogs/dev.py +++ b/jarvis/cogs/dev.py @@ -201,8 +201,15 @@ class DevCog(commands.Cog): ], ) async def _encode(self, ctx: SlashContext, method: str, data: str) -> None: + mstr = method method = getattr(base64, method + "encode") - await ctx.send(f"`{method(data.encode('UTF-8')).decode('UTF-8')}`") + encoded = method(data.encode("UTF-8")).decode("UTF-8") + fields = [ + Field(name="Plaintext", value=f"`{data}`", inline=False), + Field(name=mstr, value=f"`{encoded}`", inline=False), + ] + embed = build_embed(title="Decoded Data", description="", fields=fields) + await ctx.send(embed=embed) @cog_ext.cog_slash( name="decode", @@ -224,6 +231,7 @@ class DevCog(commands.Cog): ], ) async def _decode(self, ctx: SlashContext, method: str, data: str) -> None: + mstr = method method = getattr(base64, method + "decode") decoded = method(data.encode("UTF-8")).decode("UTF-8") if invites.search(decoded): @@ -232,7 +240,12 @@ class DevCog(commands.Cog): hidden=True, ) return - await ctx.send(f"`{decoded}`") + fields = [ + Field(name="Plaintext", value=f"`{data}`", inline=False), + Field(name=mstr, value=f"`{decoded}`", inline=False), + ] + embed = build_embed(title="Decoded Data", description="", fields=fields) + await ctx.send(embed=embed) @cog_ext.cog_slash( name="cloc", diff --git a/jarvis/cogs/util.py b/jarvis/cogs/util.py index e574546..900c8b9 100644 --- a/jarvis/cogs/util.py +++ b/jarvis/cogs/util.py @@ -15,6 +15,7 @@ from PIL import Image, ImageDraw import jarvis from jarvis import jarvis_self, logo from jarvis.config import get_config +from jarvis.data import pigpen from jarvis.data.robotcamo import emotes, hk, names from jarvis.utils import build_embed, convert_bytesize, get_repo_hash from jarvis.utils.field import Field @@ -304,6 +305,25 @@ class UtilCog(commands.Cog): hidden=True, ) + @cog_ext.cog_slash( + name="pigpen", + description="Encode a string into pigpen", + options=[create_option(name="text", description="Text to encode", option_type=3, required=True)], + ) + async def _pigpen(self, ctx: SlashContext, text: str) -> None: + outp = "`" + for c in text: + c = c.lower() + if c.lower() in pigpen.lookup: + c = pigpen.lookup[c.lower()] + elif c == " ": + c = " " + elif c == "`": + continue + outp += c + " " + outp += "`" + await ctx.send(outp[:2000]) + def setup(bot: commands.Bot) -> None: """Add UtilCog to J.A.R.V.I.S.""" diff --git a/jarvis/data/pigpen.py b/jarvis/data/pigpen.py new file mode 100644 index 0000000..272391f --- /dev/null +++ b/jarvis/data/pigpen.py @@ -0,0 +1,29 @@ +"""Pigpen lookup.""" +lookup = { + "a": "⌟", + "b": "⊔", + "c": "∟", + "d": "⊐", + "e": "□", + "f": "⊏", + "g": "⌝", + "h": "⊓", + "i": "⌜", + "j": "⟓", + "k": "ᕫ", + "l": "Ŀ", + "m": "ᑔ", + "n": "🝕", + "o": "⪽", + "p": "ᒬ", + "q": "⩀", + "r": "⟔", + "s": "V", + "t": ">", + "u": "<", + "v": "Λ", + "w": "⟇", + "x": "ᐷ", + "y": "⋖", + "z": "⟑", +}