diff --git a/cogs/chat.py b/cogs/chat.py index 2f03f48..598f82f 100644 --- a/cogs/chat.py +++ b/cogs/chat.py @@ -48,6 +48,7 @@ class ChatCog(commands.Cog): should_reply = False is_proactive = False + reply_context = "" # Text of the message being replied to # Check if bot is @mentioned if self.bot.user in message.mentions: @@ -63,6 +64,8 @@ class ChatCog(commands.Cog): ) if ref_msg.author.id == self.bot.user.id: should_reply = True + if ref_msg.content: + reply_context = f"[Replying to bot's message: {ref_msg.content[:300]}]\n" except discord.HTTPException: pass @@ -143,7 +146,7 @@ class ChatCog(commands.Cog): score_context = f"[Server context: {message.author.display_name} — {', '.join(context_parts)}]" self._chat_history[ch_id].append( - {"role": "user", "content": f"{score_context}\n{message.author.display_name}: {content}"} + {"role": "user", "content": f"{score_context}\n{reply_context}{message.author.display_name}: {content}"} ) active_prompt = self._get_active_prompt()