Merge branch 'master' of github.com:senseab/saysthbot-reborn

This commit is contained in:
Sense T 2023-05-10 01:36:35 +00:00
commit d66a1fdf35
4 changed files with 9 additions and 1 deletions

1
Cargo.lock generated
View File

@ -1858,6 +1858,7 @@ dependencies = [
"futures",
"migration",
"models",
"reqwest",
"sea-orm",
"strfmt",
"teloxide",

View File

@ -12,6 +12,7 @@ wd_log = "0.1.5"
futures = "^0.3"
#lazy_static = "*"
strfmt = "^0.1.6"
reqwest= "^0.11"
[dependencies.clap]
version = "3.2.6"

View File

@ -1,6 +1,7 @@
use clap::Parser;
const DEFAULT_DATABASE: &'static str = "sqlite:///saysthbot.db";
const DEFAULT_API_URL: &'static str = "https://api.telegram.org";
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
@ -16,4 +17,8 @@ pub struct Args {
/// Database URI
#[clap(short, long, value_parser, env = "DATABASE_URI", default_value=DEFAULT_DATABASE)]
pub database_uri: String,
/// Api Server URL
#[clap(long, value_parser, env = "API_URL", default_value=DEFAULT_API_URL)]
pub api_url: String,
}

View File

@ -24,7 +24,8 @@ impl BotServer {
/// Create new bot
pub async fn new(config: Args) -> Result<Self, DbErr> {
Ok(Self {
bot: Bot::new(config.tgbot_token),
bot: Bot::new(config.tgbot_token)
.set_api_url(reqwest::Url::parse(config.api_url.as_str()).unwrap()),
controller: Controller::new(config.database_uri).await?,
})
}