mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
aaf99d7a30
* * add clear command to clear chat history * check nil * * update comment
21 lines
508 B
Go
21 lines
508 B
Go
package commands
|
|
|
|
import "context"
|
|
|
|
func clearCommand() Definition {
|
|
return Definition{
|
|
Name: "clear",
|
|
Description: "Clear the chat history",
|
|
Usage: "/clear",
|
|
Handler: func(_ context.Context, req Request, rt *Runtime) error {
|
|
if rt == nil || rt.ClearHistory == nil {
|
|
return req.Reply(unavailableMsg)
|
|
}
|
|
if err := rt.ClearHistory(); err != nil {
|
|
return req.Reply("Failed to clear chat history: " + err.Error())
|
|
}
|
|
return req.Reply("Chat history cleared!")
|
|
},
|
|
}
|
|
}
|