diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-07-30 19:24:41 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2021-07-30 19:24:41 +0200 |
commit | 99968c72a5efbd535362e050baf314f9e0cff709 (patch) | |
tree | 910f43a609186a5719b345632fc80d218cb7b627 /src/main.rs | |
parent | bba0f862251c737e576c949320f2eecf15a74057 (diff) |
refactor: browser as modular funcs
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 13 |
1 files changed, 5 insertions, 8 deletions
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<dyn Error>> { 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<AutoSend<Bot>, Message>| { @@ -44,7 +42,6 @@ async fn main() -> Result<(), Box<dyn Error>> { .await; log::info!("Closing bot... Goodbye!"); - driver.quit().await?; Ok(()) } |