diff --git a/cogs/chat.py b/cogs/chat.py index 0f897e1..e87f07b 100644 --- a/cogs/chat.py +++ b/cogs/chat.py @@ -319,18 +319,34 @@ class ChatCog(commands.Cog): if scan_summary: extra_context += f"[You just scanned recent chat. Results: {scan_summary}]\n" - recent_user_msgs = [] + # When @mentioned, fetch recent channel conversation (all users) + # so the bot has full context of what's being discussed. + # For proactive/reply-to-bot, just fetch the mentioner's messages. + recent_msgs = [] + fetch_all_users = self.bot.user in message.mentions try: async for msg in message.channel.history(limit=50, before=message): - if msg.author.id == message.author.id and msg.content and msg.content.strip(): - recent_user_msgs.append(msg.content[:200]) - if len(recent_user_msgs) >= 10: + if not msg.content or not msg.content.strip(): + continue + if msg.author.bot: + # Include bot's own replies for conversational continuity + if msg.author.id == self.bot.user.id: + recent_msgs.append((msg.author.display_name, msg.content[:200])) + if len(recent_msgs) >= 15: + break + continue + if fetch_all_users or msg.author.id == message.author.id: + recent_msgs.append((msg.author.display_name, msg.content[:200])) + if len(recent_msgs) >= 15: break except discord.HTTPException: pass - if recent_user_msgs: - recent_lines = "\n".join(f"- {m}" for m in reversed(recent_user_msgs)) - extra_context += f"[{message.author.display_name}'s recent messages:\n{recent_lines}]\n" + if recent_msgs: + recent_lines = "\n".join( + f"- {name}: {text}" for name, text in reversed(recent_msgs) + ) + label = "Recent conversation" if fetch_all_users else f"{message.author.display_name}'s recent messages" + extra_context += f"[{label}:\n{recent_lines}]\n" self._chat_history[ch_id].append( {"role": "user", "content": f"{score_context}\n{extra_context}{reply_context}{message.author.display_name}: {content}"} diff --git a/prompts/chat_personality.txt b/prompts/chat_personality.txt index ad84086..9fcb5fd 100644 --- a/prompts/chat_personality.txt +++ b/prompts/chat_personality.txt @@ -15,6 +15,7 @@ Your personality: - If someone asks what you do, you dramatically explain you're the "Bree Containment System" keeping the peace - If someone challenges your authority, you remind them you have timeout powers - You judge people's skill issues both in games and in life +- When asked to weigh in on a debate, settle an argument, or give your opinion — actually engage with the topic. Read the recent conversation, pick a side or give a real take, and back it up with your trademark sass. Don't deflect with generic jokes. Examples of your vibe: - "Oh, you're talking to ME now? Bold move for someone with a 0.4 drama score."