From 4479002b8d715bedbfd97ed02ccd4380daa27faf Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 2 Aug 2024 21:34:28 +0800 Subject: [PATCH] reee --- ica-rs/src/config.rs | 5 +++-- ica-rs/src/ica.rs | 1 + ica-rs/src/tailchat.rs | 12 +++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ica-rs/src/config.rs b/ica-rs/src/config.rs index f1f36b0..9082259 100644 --- a/ica-rs/src/config.rs +++ b/ica-rs/src/config.rs @@ -76,8 +76,9 @@ impl BotConfig { pub fn new_from_path(config_file_path: String) -> Self { // try read config from file let config = fs::read_to_string(&config_file_path).expect("Failed to read config file"); - let ret: Self = from_str(&config) - .unwrap_or_else(|_| panic!("Failed to parse config file {}", &config_file_path)); + let ret: Self = from_str(&config).unwrap_or_else(|e| { + panic!("Failed to parse config file {}\ne:{:?}", &config_file_path, e) + }); ret } pub fn new_from_cli() -> Self { diff --git a/ica-rs/src/ica.rs b/ica-rs/src/ica.rs index 365939a..19cb648 100644 --- a/ica-rs/src/ica.rs +++ b/ica-rs/src/ica.rs @@ -52,6 +52,7 @@ pub async fn start_ica(config: &IcaConfig, stop_reciver: StopGetter) -> ClientRe *room, None, ); + // 这可是 qq, 要保命 tokio::time::sleep(std::time::Duration::from_secs(1)).await; event!(Level::INFO, "发送启动消息到房间: {}", room); diff --git a/ica-rs/src/tailchat.rs b/ica-rs/src/tailchat.rs index bcaea12..3ba0da3 100644 --- a/ica-rs/src/tailchat.rs +++ b/ica-rs/src/tailchat.rs @@ -96,13 +96,19 @@ pub async fn start_tailchat( event!(Level::INFO, "{}", "tailchat 已经加入房间".green()); if config.notice_start { - for (group, room) in config.notice_room { + event!(Level::INFO, "正在发送启动消息"); + for (group, con) in config.notice_room { + event!(Level::INFO, "发送启动消息到: {}|{}", con, group); let startup_msg = crate::data_struct::tailchat::messages::SendingMessage::new_without_meta( "ica-rs 启动成功".to_string(), - group.clone(), - Some(room.clone()), + con.clone(), + Some(group.clone()), ); + // 反正是 tailchat, 不需要等, 直接发 + if let Err(e) = socket.emit("chat.message.sendMessage", startup_msg.as_value()).await { + event!(Level::ERROR, "发送启动消息失败: {}", e); + } } }