summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/main.rs b/src/main.rs
index abe7f2e..0ac5a4d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,24 +1,12 @@
use std::error::Error;
use teloxide::prelude::*;
-use teloxide::utils::command::BotCommand;
+use thirtyfour::WebDriver;
-#[derive(BotCommand)]
-#[command(rename = "lowercase", description = "These commands are supported:")]
-enum Command {
- #[command(description = "display this text")]
- Help,
-}
-
-async fn handler(
- cx: UpdateWithCx<AutoSend<Bot>, Message>,
- command: Command,
-) -> Result<(), Box<dyn Error + Send + Sync>> {
- match command {
- Command::Help => cx.answer(Command::descriptions()).await?,
- };
+mod browser;
+mod commands;
+mod config;
- Ok(())
-}
+use crate::config::Config;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
@@ -26,8 +14,17 @@ async fn main() -> Result<(), Box<dyn Error>> {
log::info!("Starting bot...");
let bot = Bot::from_env().auto_send();
+ let config = Config::from_env().unwrap();
- teloxide::commands_repl(bot, "unict-reservation", handler).await;
+ 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(())
}