From d10acc992a8cde99bb2bac8761814d38585a4d93 Mon Sep 17 00:00:00 2001 From: Akulij Date: Tue, 27 May 2025 14:21:36 +0500 Subject: [PATCH] start bot instances in main --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.rs b/src/main.rs index bae49bb..dbc2786 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,9 +8,11 @@ pub mod message_answerer; pub mod mongodb_storage; pub mod utils; +use bot_manager::start_bot; use botscript::{BotMessage, Runner, RunnerConfig, ScriptError, ScriptResult}; use commands::BotCommand; use db::application::Application; +use db::bots::BotInstance; use db::callback_info::CallbackInfo; use db::message_forward::MessageForward; use itertools::Itertools; @@ -180,6 +182,11 @@ async fn main() -> Result<(), Box> { let mut bc = BotController::new(&config).await?; let state_mgr = MongodbStorage::open(config.db_url.clone().as_ref(), "gongbot", Json).await?; + for bi in BotInstance::get_all(&mut bc.db).await? { + let info = start_bot(bi, &mut bc.db).await?; + println!("Started bot: {}", info.name); + } + // TODO: delete this in production // allow because values are hardcoded and if they will be unparsable // we should panic anyway