feat: Introduce /ame command group and update related commands for Ame-chan AI
This commit is contained in:
parent
b803380573
commit
eef0d99817
@ -94,6 +94,11 @@ class TetoCog(commands.Cog):
|
||||
self.tavily_max_results = int(os.getenv("TAVILY_DEFAULT_MAX_RESULTS", "5"))
|
||||
self._allow_web_search = bool(self.tavily_api_key) # Enable web search if API key is available
|
||||
|
||||
# Define the /ame command group
|
||||
self.ame_group = app_commands.Group(name="ame", description="Main command group for Ame-chan AI.") # Slightly changed description
|
||||
# Define the /ame model subgroup
|
||||
self.model_subgroup = app_commands.Group(parent=self.ame_group, name="model", description="Subgroup for AI model related commands.") # Slightly changed description
|
||||
|
||||
async def _execute_shell_command(self, command: str) -> str:
|
||||
"""Executes a shell command and returns its output, limited to first 5 lines."""
|
||||
try:
|
||||
@ -532,20 +537,20 @@ class TetoCog(commands.Cog):
|
||||
await channel.send(f"**Teto AI conversation failed! TwT**\n{e}")
|
||||
log.error(f"[TETO DEBUG] Exception during AI reply: {e}")
|
||||
|
||||
@app_commands.command(name="set_ai_model", description="Sets the AI model for Teto.")
|
||||
@self.ame_group.command(name="set_ai_model", description="Sets the AI model for Ame-chan.")
|
||||
@app_commands.describe(model_name="The name of the AI model to use.")
|
||||
async def set_ai_model(self, interaction: discord.Interaction, model_name: str):
|
||||
async def set_ai_model(self, interaction: discord.Interaction, model_name: str): # Ensuring self is the first param
|
||||
self._ai_model = model_name
|
||||
await interaction.response.send_message(f"Teto's AI model set to: {model_name} desu~", ephemeral=True)
|
||||
await interaction.response.send_message(f"Ame-chan's AI model set to: {model_name} desu~", ephemeral=True)
|
||||
|
||||
@app_commands.command(name="set_api_endpoint", description="Sets the API endpoint for Teto.")
|
||||
@self.ame_group.command(name="set_api_endpoint", description="Sets the API endpoint for Ame-chan.")
|
||||
@app_commands.describe(endpoint_url="The URL of the API endpoint.")
|
||||
async def set_api_endpoint(self, interaction: discord.Interaction, endpoint_url: str):
|
||||
async def set_api_endpoint(self, interaction: discord.Interaction, endpoint_url: str): # Ensuring self is the first param
|
||||
self._api_endpoint = endpoint_url
|
||||
await interaction.response.send_message(f"Teto's API endpoint set to: {endpoint_url} desu~", ephemeral=True)
|
||||
await interaction.response.send_message(f"Ame-chan's API endpoint set to: {endpoint_url} desu~", ephemeral=True)
|
||||
|
||||
@app_commands.command(name="clear_chat_history", description="Clears the chat history for the current channel.")
|
||||
async def clear_chat_history(self, interaction: discord.Interaction):
|
||||
@self.ame_group.command(name="clear_chat_history", description="Clears the chat history for the current channel.")
|
||||
async def clear_chat_history(self, interaction: discord.Interaction): # Ensuring self is the first param
|
||||
channel_id = interaction.channel_id
|
||||
if channel_id in _teto_conversations:
|
||||
del _teto_conversations[channel_id]
|
||||
@ -553,25 +558,25 @@ class TetoCog(commands.Cog):
|
||||
else:
|
||||
await interaction.response.send_message("No chat history found for this channel desu~", ephemeral=True)
|
||||
|
||||
@app_commands.command(name="toggle_shell_command", description="Toggles Teto's ability to run shell commands.")
|
||||
async def toggle_shell_command(self, interaction: discord.Interaction):
|
||||
@self.ame_group.command(name="toggle_shell_command", description="Toggles Ame-chan's ability to run shell commands.")
|
||||
async def toggle_shell_command(self, interaction: discord.Interaction): # Ensuring self is the first param
|
||||
self._allow_shell_commands = not self._allow_shell_commands
|
||||
status = "enabled" if self._allow_shell_commands else "disabled"
|
||||
await interaction.response.send_message(f"Teto's shell command ability is now {status} desu~", ephemeral=True)
|
||||
await interaction.response.send_message(f"Ame-chan's shell command ability is now {status} desu~", ephemeral=True)
|
||||
|
||||
@app_commands.command(name="toggle_web_search", description="Toggles Teto's ability to search the web.")
|
||||
async def toggle_web_search(self, interaction: discord.Interaction):
|
||||
@self.ame_group.command(name="toggle_web_search", description="Toggles Ame-chan's ability to search the web.")
|
||||
async def toggle_web_search(self, interaction: discord.Interaction): # Ensuring self is the first param
|
||||
if not self.tavily_api_key or not self.tavily_client:
|
||||
await interaction.response.send_message("Web search is not available because the Tavily API key is not configured. Please set the TAVILY_API_KEY environment variable.", ephemeral=True)
|
||||
return
|
||||
|
||||
self._allow_web_search = not self._allow_web_search
|
||||
status = "enabled" if self._allow_web_search else "disabled"
|
||||
await interaction.response.send_message(f"Teto's web search ability is now {status} desu~", ephemeral=True)
|
||||
await interaction.response.send_message(f"Ame-chan's web search ability is now {status} desu~", ephemeral=True)
|
||||
|
||||
@app_commands.command(name="web_search", description="Search the web using Tavily API.")
|
||||
@self.ame_group.command(name="web_search", description="Search the web using Tavily API.")
|
||||
@app_commands.describe(query="The search query to look up online.")
|
||||
async def web_search_command(self, interaction: discord.Interaction, query: str):
|
||||
async def web_search_command(self, interaction: discord.Interaction, query: str): # Ensuring self is the first param
|
||||
if not self.tavily_api_key or not self.tavily_client:
|
||||
await interaction.response.send_message("Web search is not available because the Tavily API key is not configured. Please set the TAVILY_API_KEY environment variable.", ephemeral=True)
|
||||
return
|
||||
@ -605,6 +610,9 @@ class TetoCog(commands.Cog):
|
||||
except Exception as e:
|
||||
await interaction.followup.send(f"❌ Error performing web search: {str(e)}")
|
||||
|
||||
@self.model_subgroup.command(name="get", description="Gets the current AI model for Ame-chan.")
|
||||
async def get_ai_model(self, interaction: discord.Interaction): # Ensuring self is the first param
|
||||
await interaction.response.send_message(f"Ame-chan's current AI model is: {self._ai_model} desu~", ephemeral=True)
|
||||
|
||||
# Context menu command must be defined at module level
|
||||
@app_commands.context_menu(name="Teto AI Reply")
|
||||
@ -648,5 +656,6 @@ async def teto_context_menu_ai_reply(interaction: discord.Interaction, message:
|
||||
async def setup(bot: commands.Bot):
|
||||
cog = TetoCog(bot)
|
||||
await bot.add_cog(cog)
|
||||
bot.tree.add_command(cog.ame_group) # Register the command group
|
||||
bot.tree.add_command(teto_context_menu_ai_reply)
|
||||
print("TetoCog loaded! desu~")
|
||||
|
Loading…
x
Reference in New Issue
Block a user