mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-05-21 23:24:44 +02:00
Add !clear command and simplify !reset confirmation message
Both !clear and !reset now respond with "Conversation memory cleared." Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6a67fe1940
commit
8001de46c7
3 changed files with 20 additions and 4 deletions
17
meshai/commands/clear.py
Normal file
17
meshai/commands/clear.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"""Clear command handler (alias for !reset)."""
|
||||
|
||||
from .base import CommandContext, CommandHandler
|
||||
|
||||
|
||||
class ClearCommand(CommandHandler):
|
||||
"""Clear conversation history and summary."""
|
||||
|
||||
name = "clear"
|
||||
description = "Clear your chat history"
|
||||
usage = "!clear"
|
||||
|
||||
async def execute(self, args: str, context: CommandContext) -> str:
|
||||
"""Clear conversation history and summary for the sender."""
|
||||
await context.history.clear_history(context.sender_id)
|
||||
await context.history.clear_summary(context.sender_id)
|
||||
return "Conversation memory cleared."
|
||||
|
|
@ -169,6 +169,7 @@ def create_dispatcher(
|
|||
Returns:
|
||||
Configured CommandDispatcher
|
||||
"""
|
||||
from .clear import ClearCommand
|
||||
from .help import HelpCommand
|
||||
from .ping import PingCommand
|
||||
from .reset import ResetCommand
|
||||
|
|
@ -178,6 +179,7 @@ def create_dispatcher(
|
|||
dispatcher = CommandDispatcher(prefix=prefix, disabled_commands=disabled_commands)
|
||||
|
||||
# Register all built-in commands
|
||||
dispatcher.register(ClearCommand())
|
||||
dispatcher.register(HelpCommand(dispatcher))
|
||||
dispatcher.register(PingCommand())
|
||||
dispatcher.register(ResetCommand())
|
||||
|
|
|
|||
|
|
@ -17,7 +17,4 @@ class ResetCommand(CommandHandler):
|
|||
# Also clear the conversation summary
|
||||
await context.history.clear_summary(context.sender_id)
|
||||
|
||||
if deleted > 0:
|
||||
return f"Cleared {deleted} messages from history"
|
||||
else:
|
||||
return "No history to clear"
|
||||
return "Conversation memory cleared."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue