introduce db pool type instead of hard-coded SqlitePool
This commit is contained in:
parent
1e6d671feb
commit
7fac64f8e4
2 changed files with 7 additions and 4 deletions
|
|
@ -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<T>(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(())
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue