From 2f14f7edf29bd7010e5f8be8691a907c8ede1278 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Sat, 31 Jul 2021 11:51:25 +0200 Subject: First basic testing zizek bot --- src/main.rs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index e7a11a9..a3b1f64 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,35 @@ -fn main() { - println!("Hello, world!"); +#![warn(missing_docs)] + +//! In case you and your friends ever felt like you don't have enough +//! Slavoj Žižek in your life, this matrix bot can help you satisfying that +//! need. + +use std::sync::{Arc, Mutex}; + +use matrix_bot_api::MatrixBot; + +pub mod bot_config; +pub mod command_handler; +pub mod zizek_db; + +use bot_config::BotConfig; +use command_handler::CommandHandler; +use zizek_db::ZizekDb; + +fn main() +{ + let bot_config = BotConfig::from_config_file().expect("Unable to read bot configuration file"); + let zizek_db = Arc::new(Mutex::new( + ZizekDb::from_file("zizek_quotes.db").expect("Unable to load zizek quote database"), + )); + + /* The command handler is the handler with the highest priority, so it gets + * registered first */ + let bot = MatrixBot::new(CommandHandler::new(zizek_db.clone())); + + bot.run( + bot_config.user(), + bot_config.password(), + bot_config.homeserver_url(), + ); } -- cgit v1.2.3-70-g09d2