Skip to content

Commit

Permalink
Update text.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleysigma committed Oct 23, 2023
1 parent 42a74ca commit 58625f4
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions uqcsbot/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@ async def encoding_autocomplete(
class Text(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
## self.zalgo_menu = app_commands.ContextMenu(
## name="Zalgo",
## callback=self.zalgo_context,
## )
## self.bot.tree.add_command(self.zalgo_menu)
##
## self.mock_menu = app_commands.ContextMenu(
## name="Mock",
## callback=self.mock_context,
## )
## self.bot.tree.add_command(self.mock_menu)
##
## self.rot_13_menu = app_commands.ContextMenu(
## name="ROT13",
## callback=self.rot_13_context,
## )
## self.bot.tree.add_command(self.rot_13_menu)

## self.zalgo_menu = app_commands.ContextMenu(
## name="Zalgo",
## callback=self.zalgo_context,
## )
## self.bot.tree.add_command(self.zalgo_menu)
##
## self.mock_menu = app_commands.ContextMenu(
## name="Mock",
## callback=self.mock_context,
## )
## self.bot.tree.add_command(self.mock_menu)
##
## self.rot_13_menu = app_commands.ContextMenu(
## name="ROT13",
## callback=self.rot_13_context,
## )
## self.bot.tree.add_command(self.rot_13_menu)

self.rot_13_secret_menu = app_commands.ContextMenu(
name="ROT13 (Secret)",
callback=self.rot_13_secret_context,
Expand Down Expand Up @@ -290,9 +290,9 @@ def rot_13_cipher(self, text: str) -> str:
result = ""
for c in text:
if "a" <= c <= "m" or "A" <= c <= "M":
result += chr(ord(c)+13)
result += chr(ord(c) + 13)
elif "n" <= c <= "z" or "N" <= c <= "Z":
result += chr(ord(c)-13)
result += chr(ord(c) - 13)
else:
result += c
return result
Expand All @@ -306,21 +306,24 @@ async def rot_13_command(self, interaction: discord.Interaction, text: str):
"""
await interaction.response.send_message(self.rot_13_cipher(text))

## async def rot_13_context(
## self, interaction: discord.Interaction, message: discord.Message
## ):
## """
## Encodes this message with the cunning ROT13 Cipher
## """
## await interaction.response.send_message(self.rot_13_cipher(message.content))
## async def rot_13_context(
## self, interaction: discord.Interaction, message: discord.Message
## ):
## """
## Encodes this message with the cunning ROT13 Cipher
## """
## await interaction.response.send_message(self.rot_13_cipher(message.content))

async def rot_13_secret_context(
self, interaction: discord.Interaction, message: discord.Message
):
"""
Encodes this message with the cunning ROT13 Cipher, and shows it secretly to the caller
"""
await interaction.response.send_message(self.rot_13_cipher(message.content), ephemeral=True)
await interaction.response.send_message(
self.rot_13_cipher(message.content), ephemeral=True
)


async def setup(bot: commands.Bot):
await bot.add_cog(Text(bot))

0 comments on commit 58625f4

Please sign in to comment.