Restore any bot connections that were previously saved to disk.
()
| 70 | |
| 71 | /// Restore any bot connections that were previously saved to disk. |
| 72 | async fn restore_saved_bots() { |
| 73 | use bitfun_core::service::remote_connect::bot; |
| 74 | |
| 75 | let data = bot::load_bot_persistence(); |
| 76 | if data.connections.is_empty() { |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | let holder = get_service_holder(); |
| 81 | let guard = holder.read().await; |
| 82 | let Some(service) = guard.as_ref() else { |
| 83 | return; |
| 84 | }; |
| 85 | |
| 86 | for conn in &data.connections { |
| 87 | if !conn.chat_state.paired { |
| 88 | continue; |
| 89 | } |
| 90 | log::info!( |
| 91 | "Restoring {} bot connection for chat_id={}", |
| 92 | conn.bot_type, |
| 93 | conn.chat_id |
| 94 | ); |
| 95 | let result = service.restore_bot(conn).await; |
| 96 | if let Err(e) = result { |
| 97 | log::warn!("Failed to restore {} bot: {e}", conn.bot_type); |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /// Auto-detect the mobile-web build output directory. |
| 103 | fn detect_mobile_web_dir() -> Option<String> { |
no test coverage detected