Add pigpen, remove bug in encode/decode that allowed for pings
This commit is contained in:
parent
1cacb2979a
commit
647740520d
4 changed files with 65 additions and 3 deletions
|
@ -41,7 +41,7 @@ jarvis = commands.Bot(
|
||||||
|
|
||||||
slash = SlashCommand(jarvis, sync_commands=False, sync_on_cog_reload=True)
|
slash = SlashCommand(jarvis, sync_commands=False, sync_on_cog_reload=True)
|
||||||
jarvis_self = Process()
|
jarvis_self = Process()
|
||||||
__version__ = "1.11.0"
|
__version__ = "1.11.1"
|
||||||
|
|
||||||
|
|
||||||
@jarvis.event
|
@jarvis.event
|
||||||
|
|
|
@ -201,8 +201,15 @@ class DevCog(commands.Cog):
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def _encode(self, ctx: SlashContext, method: str, data: str) -> None:
|
async def _encode(self, ctx: SlashContext, method: str, data: str) -> None:
|
||||||
|
mstr = method
|
||||||
method = getattr(base64, method + "encode")
|
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(
|
@cog_ext.cog_slash(
|
||||||
name="decode",
|
name="decode",
|
||||||
|
@ -224,6 +231,7 @@ class DevCog(commands.Cog):
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def _decode(self, ctx: SlashContext, method: str, data: str) -> None:
|
async def _decode(self, ctx: SlashContext, method: str, data: str) -> None:
|
||||||
|
mstr = method
|
||||||
method = getattr(base64, method + "decode")
|
method = getattr(base64, method + "decode")
|
||||||
decoded = method(data.encode("UTF-8")).decode("UTF-8")
|
decoded = method(data.encode("UTF-8")).decode("UTF-8")
|
||||||
if invites.search(decoded):
|
if invites.search(decoded):
|
||||||
|
@ -232,7 +240,12 @@ class DevCog(commands.Cog):
|
||||||
hidden=True,
|
hidden=True,
|
||||||
)
|
)
|
||||||
return
|
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(
|
@cog_ext.cog_slash(
|
||||||
name="cloc",
|
name="cloc",
|
||||||
|
|
|
@ -15,6 +15,7 @@ from PIL import Image, ImageDraw
|
||||||
import jarvis
|
import jarvis
|
||||||
from jarvis import jarvis_self, logo
|
from jarvis import jarvis_self, logo
|
||||||
from jarvis.config import get_config
|
from jarvis.config import get_config
|
||||||
|
from jarvis.data import pigpen
|
||||||
from jarvis.data.robotcamo import emotes, hk, names
|
from jarvis.data.robotcamo import emotes, hk, names
|
||||||
from jarvis.utils import build_embed, convert_bytesize, get_repo_hash
|
from jarvis.utils import build_embed, convert_bytesize, get_repo_hash
|
||||||
from jarvis.utils.field import Field
|
from jarvis.utils.field import Field
|
||||||
|
@ -304,6 +305,25 @@ class UtilCog(commands.Cog):
|
||||||
hidden=True,
|
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:
|
def setup(bot: commands.Bot) -> None:
|
||||||
"""Add UtilCog to J.A.R.V.I.S."""
|
"""Add UtilCog to J.A.R.V.I.S."""
|
||||||
|
|
29
jarvis/data/pigpen.py
Normal file
29
jarvis/data/pigpen.py
Normal 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": "⟑",
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue