summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: a3b1f646a1fccf6fd42e0d136830700b6cd47194 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#![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(),
    );
}