Skip to content

Commit

Permalink
fix reply history for chatgpt
Browse files Browse the repository at this point in the history
  • Loading branch information
ropc committed Feb 24, 2024
1 parent 6935267 commit 311b7af
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions memebot/cogs/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ def __init__(self, bot_id: int):

@commands.Cog.listener()
async def on_message(self, message: discord.Message):
if message.author.bot or len(message.mentions) != 1 or message.mentions[0].id != self.bot_id:
if message.author.bot:
return
replied_message = await self.get_replied_message(message)
bot_was_replied = replied_message and replied_message.author.id == self.bot_id
bot_was_mentioned = len(message.mentions) == 1 and message.mentions[0].id == self.bot_id
if not (bot_was_mentioned or bot_was_replied):
return
message_history = [m async for m in self.get_reply_history(message)]

completion = self.client.chat.completions.create(
model="gpt-3.5-turbo",
Expand Down

0 comments on commit 311b7af

Please sign in to comment.