Fix conversation limit thread closing logic for other users

Return early on conversation processing if the conversation limit is reached
Rene Teigen 2 years ago
parent b48306be44
commit fc70fd5734

@ -267,12 +267,8 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
# If at conversation limit then fetch the owner and close the thread for them # If at conversation limit then fetch the owner and close the thread for them
if conversation_limit: if conversation_limit:
try: try:
owner_id = list(self.conversation_thread_owners.keys())[ owner_id = [owner for owner, threads in self.conversation_thread_owners.items() if channel_id in threads][0]
list( self.conversation_thread_owners[owner_id].remove(
[value for value in self.conversation_thread_owners.values()]
).index(channel_id)
]
self.conversation_thread_owners[normalized_user_id].remove(
ctx.channel.id ctx.channel.id
) )
# Attempt to close and lock the thread. # Attempt to close and lock the thread.
@ -480,6 +476,8 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
"You have reached the maximum conversation length. You have ended the conversation with GPT3, and it has ended." "You have reached the maximum conversation length. You have ended the conversation with GPT3, and it has ended."
) )
await self.end_conversation(message, conversation_limit=True) await self.end_conversation(message, conversation_limit=True)
return True
return False
async def summarize_conversation(self, message, prompt): async def summarize_conversation(self, message, prompt):
"""Takes a conversation history filled prompt and summarizes it to then start a new history with it as the base""" """Takes a conversation history filled prompt and summarizes it to then start a new history with it as the base"""

@ -543,7 +543,8 @@ class TextService:
prompt = await converser_cog.mention_to_username(message, content) prompt = await converser_cog.mention_to_username(message, content)
await converser_cog.check_conversation_limit(message) if await converser_cog.check_conversation_limit(message):
return
# If the user is in a conversation thread # If the user is in a conversation thread
if message.channel.id in converser_cog.conversation_threads: if message.channel.id in converser_cog.conversation_threads:

Loading…
Cancel
Save