summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 0ac5a4d7f07c30a57c371373bb45da3a448a1b3d (plain)
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
use std::error::Error;
use teloxide::prelude::*;
use thirtyfour::WebDriver;

mod browser;
mod commands;
mod config;

use crate::config::Config;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    teloxide::enable_logging!();
    log::info!("Starting bot...");

    let bot = Bot::from_env().auto_send();
    let config = Config::from_env().unwrap();

    let driver: WebDriver = browser::init().await;
    match browser::login(&driver, &config).await {
        Ok(_) => {}
        Err(e) => {
            panic!("You can't connect: `{}`, credentials are {:?}", e, config);
        }
    };
    teloxide::commands_repl(bot, "unict-reservation", commands::handler).await;

    log::info!("Closing bot... Goodbye!");
    Ok(())
}