custom api url
This commit is contained in:
parent
485837dcbe
commit
e1979eaa40
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1858,6 +1858,7 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
"migration",
|
"migration",
|
||||||
"models",
|
"models",
|
||||||
|
"reqwest",
|
||||||
"sea-orm",
|
"sea-orm",
|
||||||
"strfmt",
|
"strfmt",
|
||||||
"teloxide",
|
"teloxide",
|
||||||
|
@ -12,6 +12,7 @@ wd_log = "0.1.5"
|
|||||||
futures = "^0.3"
|
futures = "^0.3"
|
||||||
#lazy_static = "*"
|
#lazy_static = "*"
|
||||||
strfmt = "^0.1.6"
|
strfmt = "^0.1.6"
|
||||||
|
reqwest= "^0.11"
|
||||||
|
|
||||||
[dependencies.clap]
|
[dependencies.clap]
|
||||||
version = "3.2.6"
|
version = "3.2.6"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
const DEFAULT_DATABASE: &'static str = "sqlite:///saysthbot.db";
|
const DEFAULT_DATABASE: &'static str = "sqlite:///saysthbot.db";
|
||||||
|
const DEFAULT_API_URL: &'static str = "https://api.telegram.org";
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[clap(author, version, about, long_about = None)]
|
||||||
@ -16,4 +17,8 @@ pub struct Args {
|
|||||||
/// Database URI
|
/// Database URI
|
||||||
#[clap(short, long, value_parser, env = "DATABASE_URI", default_value=DEFAULT_DATABASE)]
|
#[clap(short, long, value_parser, env = "DATABASE_URI", default_value=DEFAULT_DATABASE)]
|
||||||
pub database_uri: String,
|
pub database_uri: String,
|
||||||
|
|
||||||
|
/// Api Server URL
|
||||||
|
#[clap(long, value_parser, env = "API_URL", default_value=DEFAULT_API_URL)]
|
||||||
|
pub api_url: String,
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,8 @@ impl BotServer {
|
|||||||
/// Create new bot
|
/// Create new bot
|
||||||
pub async fn new(config: Args) -> Result<Self, DbErr> {
|
pub async fn new(config: Args) -> Result<Self, DbErr> {
|
||||||
Ok(Self {
|
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?,
|
controller: Controller::new(config.database_uri).await?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user