From 99968c72a5efbd535362e050baf314f9e0cff709 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Fri, 30 Jul 2021 19:24:41 +0200 Subject: refactor: browser as modular funcs --- src/main.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index b854f49..203dca2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,5 @@ use std::error::Error; use teloxide::prelude::*; -use thirtyfour::WebDriver; - mod browser; mod commands; mod config; @@ -18,13 +16,13 @@ async fn main() -> Result<(), Box> { let bot = Bot::from_env().auto_send(); let config = Config::from_env().unwrap(); - let driver: WebDriver = browser::init(&config.driver_url).await; - match browser::login(&driver, &config).await { - Ok(_) => {} - Err(e) => { + unsafe { + browser::init(&config.driver_url).await; + + if let Err(e) = browser::login(&config).await { panic!("You can't connect: `{}`, credentials are {:?}", e, config); } - }; + } Dispatcher::new(bot) .messages_handler(|rx: DispatcherHandlerRx, Message>| { @@ -44,7 +42,6 @@ async fn main() -> Result<(), Box> { .await; log::info!("Closing bot... Goodbye!"); - driver.quit().await?; Ok(()) } -- cgit v1.2.3-18-g5258