diff --git a/README.en.md b/README.en.md index 969dca8c..0e19b8d9 100644 --- a/README.en.md +++ b/README.en.md @@ -42,6 +42,8 @@ The compiled files are available at: `./target/release/rssbot` ## Run ``` +A simple Telegram RSS bot. + USAGE: rssbot [FLAGS] [OPTIONS] @@ -54,6 +56,7 @@ FLAGS: OPTIONS: --admin ... Private mode, only specified user can use this bot. This argument can be passed multiple times to allow multiple admins + --api-uri Custom telegram api URI [default: https://api.telegram.org/] -d, --database Path to database [default: ./rssbot.json] --max-feed-size Maximum feed size, 0 is unlimited [default: 2097152] --max-interval Maximum fetch interval [default: 43200] diff --git a/README.md b/README.md index 7149c99a..a2b8ec4c 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ FLAGS: OPTIONS: --admin ... Private mode, only specified user can use this bot. This argument can be passed multiple times to allow multiple admins + --api-uri Custom telegram api URI [default: https://api.telegram.org/] -d, --database Path to database [default: ./rssbot.json] --max-feed-size Maximum feed size, 0 is unlimited [default: 2097152] --max-interval Maximum fetch interval [default: 43200] diff --git a/src/main.rs b/src/main.rs index e2f47377..51852d36 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ use hyper_proxy::{Intercept, Proxy}; use once_cell::sync::OnceCell; use structopt::StructOpt; use tbot; +use tbot::bot::Uri; use tokio::{self, sync::Mutex}; // Include the tr! macro and localizations @@ -82,6 +83,13 @@ pub struct Opt { /// Make bot commands only accessible for group admins. #[structopt(long)] restricted: bool, + /// Custom telegram api URI + #[structopt( + long, + value_name = "tgapi-uri", + default_value = "https://api.telegram.org/" + )] + api_uri: Uri, /// DANGER: Insecure mode, accept invalid TLS certificates #[structopt(long)] insecure: bool, @@ -103,12 +111,12 @@ async fn main() -> anyhow::Result<()> { let opt = Opt::from_args(); let db = Arc::new(Mutex::new(Database::open(opt.database.clone())?)); + let bot_builder = tbot::bot::Builder::with_string_token(opt.token.clone()) + .server_uri(opt.api_uri.clone()); let bot = if let Some(proxy) = init_proxy() { - tbot::bot::Builder::with_string_token(opt.token.clone()) - .proxy(proxy) - .build() + bot_builder.proxy(proxy).build() } else { - tbot::Bot::new(opt.token.clone()) + bot_builder.build() }; let me = bot .get_me()