diff --git a/Dockerfile b/Dockerfile index 009d6ee..37c4add 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,8 @@ RUN cargo run FROM rust:latest COPY --from=builder /target /target -COPY --from=builder config.ini +COPY --from=builder config.ini config.ini WORKDIR /target -RUN ./matrix-modbot +RUN ./matrix-modbot config.ini HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD curl --fail http://localhost:5000/health || exit 1 diff --git a/src/bot.rs b/src/bot.rs index 3119a66..2514307 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -1,7 +1,7 @@ #[allow(clippy::module_inception)] pub mod bot { - use crate::{config_reader::config_reader::BotUserInfo, utils}; + use crate::config_reader::config_reader::BotUserInfo; use log::{info, debug}; use matrix_sdk::{ Client, diff --git a/src/config_reader.rs b/src/config_reader.rs index ed7cc09..83e6d46 100644 --- a/src/config_reader.rs +++ b/src/config_reader.rs @@ -14,8 +14,7 @@ pub mod config_reader { } impl BotUserInfo { - pub fn get_info(config_file_path: Option<&str>) -> Result> { - let config_file_path = config_file_path.unwrap_or("config.ini"); + pub fn get_info(config_file_path: &str) -> Result> { let mut config = Ini::new(); let _map = config.load(config_file_path)?; let user_id = config.get("credentials", "user_id").unwrap(); diff --git a/src/main.rs b/src/main.rs index 7e3d561..386a7e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,18 @@ +use std::env; + +mod config_reader; +mod bot; +pub use config_reader::config_reader::BotUserInfo; +pub use bot::bot::Bot; + #[tokio::main] async fn main() { - println!("Hello, world!"); + println!("Starting Matrix-Modbot"); + let mut args: Vec = env::args().collect(); + if args.is_empty() { + args.push("config.ini".to_string()) // Set the default config file path to config.ini + } + let config_path = &args[0]; + let creds = BotUserInfo::get_info(config_path).unwrap(); + Bot::bot_login(creds); }