pub async fn trigger_command_new(
command_args: &[String],
raw_input: &str,
session_key: Option<String>,
) -> Result<InternalHookEvent>Expand description
触发 command:new 事件
当用户执行 /new 命令时调用此函数触发 command:new 事件。
事件的 context 包含 command_name、command_args 和 raw_input 字段。
§参数
command_args: 命令参数列表(如["--model", "gpt-4"])raw_input: 原始输入字符串(如/new --model gpt-4)session_key: 可选的会话键
§返回值
返回触发后的 InternalHookEvent,调用者可以访问处理器添加的消息。
§示例
ⓘ
use aster::hooks::internal::trigger_command_new;
async fn handle_new_command() {
let event = trigger_command_new(
&["--model".to_string(), "gpt-4".to_string()],
"/new --model gpt-4",
Some("session-123".to_string()),
).await.unwrap();
// 检查处理器添加的消息
for msg in &event.messages {
println!("Handler message: {}", msg);
}
}Validates: Requirements 9.1, 9.5