diff --git a/cogs/gpt_3_commands_and_converser.py b/cogs/gpt_3_commands_and_converser.py index c1f1277..36faba0 100644 --- a/cogs/gpt_3_commands_and_converser.py +++ b/cogs/gpt_3_commands_and_converser.py @@ -934,10 +934,8 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"): response_text = response_text.strip() response_text = f"***{prompt}***\n\n{response_text}" - # If GPT3 tries to ping somebody, don't let it happen + # If gpt3 tries writing a user mention try to replace it with their name response_text = await self.replace_mention(ctx, response_text) - # escape any other metnions - response_text = discord.utils.escape_mentions(response_text) # If the user is conversing, add the GPT response to their conversation history. if ( @@ -981,9 +979,12 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"): custom_api_key=custom_api_key, ) - # Cleanse + # Cleanse again response_text = self.cleanse_response(response_text) + # escape any other mentions like @here or @everyone + response_text = discord.utils.escape_mentions(response_text) + # If we don't have a response message, we are not doing a redo, send as a new message(s) if not response_message: if len(response_text) > self.TEXT_CUTOFF: diff --git a/cogs/image_prompt_optimizer.py b/cogs/image_prompt_optimizer.py index 0a08add..47ab95d 100644 --- a/cogs/image_prompt_optimizer.py +++ b/cogs/image_prompt_optimizer.py @@ -74,6 +74,7 @@ class ImgPromptOptimizer(discord.Cog, name="ImgPromptOptimizer"): user = ctx.user final_prompt = self.OPTIMIZER_PRETEXT + # replace mentions with nicknames for the prompt final_prompt += await self.converser_cog.replace_mention(ctx, prompt) # If the prompt doesn't end in a period, terminate it. @@ -100,7 +101,7 @@ class ImgPromptOptimizer(discord.Cog, name="ImgPromptOptimizer"): # also relatively cost-effective response_text = response["choices"][0]["text"] - + # escape any mentions response_text = discord.utils.escape_mentions(response_text) response_message = await ctx.respond(