diff --git a/Cargo.lock b/Cargo.lock index 264e63d..76375c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1858,6 +1858,7 @@ dependencies = [ "futures", "migration", "models", + "reqwest", "sea-orm", "strfmt", "teloxide", diff --git a/Cargo.toml b/Cargo.toml index 921123e..5d8c069 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/config.rs b/src/config.rs index 16d7549..8f55dd8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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, } diff --git a/src/telegram_bot.rs b/src/telegram_bot.rs index 31797fe..f25a419 100644 --- a/src/telegram_bot.rs +++ b/src/telegram_bot.rs @@ -24,7 +24,8 @@ impl BotServer { /// Create new bot pub async fn new(config: Args) -> Result { 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?, }) }