Update rcauto to include special characters

This commit is contained in:
Zeva Rose 2021-07-04 20:27:51 -06:00
parent d3610c42fc
commit 21979c88d7

View file

@ -1,3 +1,5 @@
import re
from discord.ext import commands from discord.ext import commands
from discord_slash import SlashContext, cog_ext from discord_slash import SlashContext, cog_ext
from discord_slash.utils.manage_commands import create_option from discord_slash.utils.manage_commands import create_option
@ -68,12 +70,26 @@ class UtilCog(commands.Cog):
], ],
) )
async def _rcauto(self, ctx: SlashContext, text: str): async def _rcauto(self, ctx: SlashContext, text: str):
lookup = {
"-": ":rcDash:",
"(": ":rcPL:",
")": ":rc:",
"$": ":rcDS:",
"@": ":rcAt:",
"!": ":rcEx:",
"?": ":rcQm:",
"^": ":rcThis:",
"'": ":rcApost:",
"#": ":rcHash:",
}
to_send = "" to_send = ""
for letter in text.upper(): for letter in text.upper():
if letter == " ": if letter == " ":
to_send += " " to_send += " "
else: elif re.match(r"^[A-Z0-9]$"):
to_send += f":rc{letter}:" to_send += f":rc{letter}:"
elif re.match(r"^[-()$@!?^'#]$"):
to_send += lookup[letter]
await ctx.send(to_send) await ctx.send(to_send)