From 8580f52d01800165ec267cfd86e6854b8d7da6c5 Mon Sep 17 00:00:00 2001 From: nsde Date: Tue, 1 Aug 2023 17:02:54 +0200 Subject: [PATCH] Small improvements --- cord/autochat.py | 17 ++++++++++++++++- cord/bot.py | 8 ++++++++ cord/credential_manager.py | 1 - 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/cord/autochat.py b/cord/autochat.py index 80d9b05..236c9dc 100644 --- a/cord/autochat.py +++ b/cord/autochat.py @@ -1,4 +1,6 @@ import embedder + + from nextcord import DMChannel async def process(message): @@ -13,7 +15,19 @@ async def process(message): return if 'N0V4x0SS' in text or 'T3BlbkFJ' in text: - await embedder.warn(message, f'{message.author.mention}, I think you sent an *OpenAI* or *NovaAI* key in here, which could lead to other users accessing your API account without your knowledge. Be very careful with API credentials!', delete_after=15) + censored_text = '' + + for word in text.split(): + if 'N0V4x0SS' in word or 'T3BlbkFJ' in word: + censored_text += '❚' * len(word) + else: + censored_text += word + censored_text += ' ' + + await embedder.warn(message, f"""{message.author.mention}, +I think you sent an *OpenAI* or *NovaAI* key in here, +which could lead to other users accessing your API account without your knowledge. +Be very careful with API credentials!""", content=f'||{message.author.mention} sent (censored version):\n```{censored_text}```||', delete_after=60) await message.delete() # COMMANDS: WRONG CHANNEL @@ -28,4 +42,5 @@ async def process(message): if text.startswith('/') and len(text) > 2: await embedder.warn(message, """Need help running commands? Check out **https://nova-oss.com/novacord**!""", delete_after=10) + await message.delete() return diff --git a/cord/bot.py b/cord/bot.py index 1c79022..455dda0 100644 --- a/cord/bot.py +++ b/cord/bot.py @@ -66,4 +66,12 @@ async def leaderboard(interaction: nextcord.Interaction): async def account(interaction: nextcord.Interaction): return await accounts.get_account(interaction) +@bot.slash_command(description='Lookup members by their Discord ID.') +async def lookup(interaction: nextcord.Interaction, + discord_id: int = SlashOption(description='Discord ID', required=True) +): + for member in interaction.guild.members: + if str(member.id).startswith(str(discord_id)): + return await embedder.ok(interaction, f'Result: {member.mention} (`{member.id}`)') + bot.run(os.getenv('DISCORD_TOKEN')) diff --git a/cord/credential_manager.py b/cord/credential_manager.py index f628d36..5fcbb35 100644 --- a/cord/credential_manager.py +++ b/cord/credential_manager.py @@ -11,7 +11,6 @@ from dotenv import load_dotenv load_dotenv() - async def get_credentials(interaction): for _ in range(2): try: