Add pigpen, remove bug in encode/decode that allowed for pings

This commit is contained in:
Zeva Rose 2021-09-30 09:38:12 -06:00
parent 1cacb2979a
commit 647740520d
4 changed files with 65 additions and 3 deletions

View file

@ -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

View file

@ -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",

View file

@ -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."""

29
jarvis/data/pigpen.py Normal file
View file

@ -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": "",
}