支持渠道、指令(自定义前缀)和事件(启用/禁用)管理

This commit is contained in:
xintaofei
2026-03-31 11:49:24 +08:00
parent 54bab306e1
commit edc12a0e39
24 changed files with 1777 additions and 330 deletions

View File

@@ -183,3 +183,45 @@ pub async fn list_chat_channel_messages(
.await?;
Ok(Json(result))
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetCommandPrefixParams {
pub prefix: String,
}
pub async fn get_chat_command_prefix(
Extension(state): Extension<Arc<AppState>>,
) -> Result<Json<String>, AppCommandError> {
let result = cc_commands::get_chat_command_prefix_core(&state.db).await?;
Ok(Json(result))
}
pub async fn set_chat_command_prefix(
Extension(state): Extension<Arc<AppState>>,
Json(params): Json<SetCommandPrefixParams>,
) -> Result<Json<()>, AppCommandError> {
cc_commands::set_chat_command_prefix_core(&state.db, params.prefix).await?;
Ok(Json(()))
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetEventFilterParams {
pub filter: Option<Vec<String>>,
}
pub async fn get_chat_event_filter(
Extension(state): Extension<Arc<AppState>>,
) -> Result<Json<Option<Vec<String>>>, AppCommandError> {
let result = cc_commands::get_chat_event_filter_core(&state.db).await?;
Ok(Json(result))
}
pub async fn set_chat_event_filter(
Extension(state): Extension<Arc<AppState>>,
Json(params): Json<SetEventFilterParams>,
) -> Result<Json<()>, AppCommandError> {
cc_commands::set_chat_event_filter_core(&state.db, params.filter).await?;
Ok(Json(()))
}

View File

@@ -193,6 +193,10 @@ pub fn build_router(state: Arc<AppState>, token: String, static_dir: std::path::
.route("/test_chat_channel", post(handlers::chat_channel::test_chat_channel))
.route("/get_chat_channel_status", post(handlers::chat_channel::get_chat_channel_status))
.route("/list_chat_channel_messages", post(handlers::chat_channel::list_chat_channel_messages))
.route("/get_chat_command_prefix", post(handlers::chat_channel::get_chat_command_prefix))
.route("/set_chat_command_prefix", post(handlers::chat_channel::set_chat_command_prefix))
.route("/get_chat_event_filter", post(handlers::chat_channel::get_chat_event_filter))
.route("/set_chat_event_filter", post(handlers::chat_channel::set_chat_event_filter))
// ─── Terminal ───
.route("/terminal_spawn", post(handlers::terminal::terminal_spawn))
.route("/terminal_write", post(handlers::terminal::terminal_write))