diff --git a/src/bot/bot.rs b/src/bot/bot.rs index 86bc818..ceb293e 100644 --- a/src/bot/bot.rs +++ b/src/bot/bot.rs @@ -5,14 +5,13 @@ use std::fmt; use std::str; use std::str::FromStr; use std::time::Duration; -use teloxide::dispatching::dialogue; -use teloxide::dispatching::dialogue::InMemStorage; -use teloxide::dispatching::UpdateHandler; +use teloxide::dispatching::{dialogue, dialogue::InMemStorage, UpdateHandler}; use teloxide::{prelude::*, update_listeners::Polling, utils::command::BotCommands}; use tracing::{event, Level}; use super::dl::cmd_download; use super::types::*; +use crate::db::DbPool; fn parse_env(name: &str) -> T where @@ -74,7 +73,7 @@ enum Command { Download(String), } -async fn cmd_test(bot: Bot, msg: Message, _db: SqlitePool) -> HandlerResult { +async fn cmd_test(bot: Bot, msg: Message, _db: DbPool) -> HandlerResult { bot.send_message(msg.chat.id, "test response").await?; Ok(()) diff --git a/src/db.rs b/src/db.rs index 9e400fc..4462801 100644 --- a/src/db.rs +++ b/src/db.rs @@ -3,6 +3,8 @@ use sqlx::{Sqlite, SqlitePool}; use super::util::make_database_url; +pub type DbPool = SqlitePool; + #[derive(sqlx::FromRow)] pub struct User { pub id: i64, @@ -14,6 +16,8 @@ pub struct User { pub is_admin: i64, } +pub mod user; + #[derive(sqlx::FromRow)] pub struct Chat { pub id: i64,