From 485837dcbe8840025db6f01b92b67cff86d2c8b8 Mon Sep 17 00:00:00 2001 From: TonyChyi Date: Fri, 5 Aug 2022 21:30:47 +0800 Subject: [PATCH 1/2] no DS_Store --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 9a874b5768f336915163bb88cd434575b859f936..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425ml0g0s}V-^m;4I%_5-~tF3k&vj^b9A16778<}(6eNJu~Vz<8=6`~ zboab&MFtUB!i}=AFfm2m$tVxGT*u4pe81nUlA49C} z?O@64YO)2RT{MRe%{!}2F))pG(Sih~)xkgosK7*lF7m<7{{#Hn{6A@7N(HFEpDCdI z{ Date: Tue, 9 May 2023 17:49:55 +0800 Subject: [PATCH 2/2] custom api url --- Cargo.lock | 1 + Cargo.toml | 1 + src/config.rs | 5 +++++ src/telegram_bot.rs | 3 ++- 4 files changed, 9 insertions(+), 1 deletion(-) 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?, }) }