|
|
@@ -22,6 +22,13 @@ user_modes = {}
|
|
|
DEFAULT_OPTIMIZATION_MODE = "balanced"
|
|
|
DEFAULT_FOCUS_MODE = "webSearch"
|
|
|
|
|
|
+HELP_TEXT = """
|
|
|
+Hello! I'm Perplexica Bot.
|
|
|
+To use me, please type `/search <your query>` to search for information.
|
|
|
+You can also change your search effort mode using `/mode`.
|
|
|
+I don't respond to direct messages or mentions outside of these commands.
|
|
|
+"""
|
|
|
+
|
|
|
# --- Discord Bot Setup ---
|
|
|
intents = discord.Intents.default()
|
|
|
intents.message_content = True
|
|
|
@@ -35,6 +42,20 @@ async def on_ready():
|
|
|
await tree.sync()
|
|
|
print("Slash commands synced.")
|
|
|
|
|
|
+@client.event
|
|
|
+async def on_message(message: discord.Message):
|
|
|
+ """Event handler for when a message is sent."""
|
|
|
+ # Ignore messages from the bot itself
|
|
|
+ if message.author == client.user:
|
|
|
+ return
|
|
|
+
|
|
|
+ # Respond to DMs or mentions
|
|
|
+ if isinstance(message.channel, discord.DMChannel) or client.user.mentioned_in(message):
|
|
|
+ await message.channel.send(HELP_TEXT)
|
|
|
+ return
|
|
|
+
|
|
|
+ await client.process_commands(message) # Important! Allows other commands to be processed.
|
|
|
+
|
|
|
# --- Slash Commands ---
|
|
|
|
|
|
@tree.command(name="search", description="Search with Perplexica")
|