Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 2d42871df587b5a533a01dda9fc83a5350a922f2
Author: Sense T <[email protected]>
Date:   Sun Oct 8 08:24:36 2023 +0000

    增加自定义 tgapi uri 选项
  • Loading branch information
Sense T authored and iovxw committed Oct 16, 2023
1 parent ff4dfc4 commit 7aedf14
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ The compiled files are available at: `./target/release/rssbot`
## Run

```
A simple Telegram RSS bot.
USAGE:
rssbot [FLAGS] [OPTIONS] <token>
Expand All @@ -54,6 +56,7 @@ FLAGS:
OPTIONS:
--admin <user id>... Private mode, only specified user can use this bot. This argument can be passed
multiple times to allow multiple admins
--api-uri <tgapi-uri> Custom telegram api URI [default: https://api.telegram.org/]
-d, --database <path> Path to database [default: ./rssbot.json]
--max-feed-size <bytes> Maximum feed size, 0 is unlimited [default: 2097152]
--max-interval <seconds> Maximum fetch interval [default: 43200]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ FLAGS:
OPTIONS:
--admin <user id>... Private mode, only specified user can use this bot. This argument can be passed
multiple times to allow multiple admins
--api-uri <tgapi-uri> Custom telegram api URI [default: https://api.telegram.org/]
-d, --database <path> Path to database [default: ./rssbot.json]
--max-feed-size <bytes> Maximum feed size, 0 is unlimited [default: 2097152]
--max-interval <seconds> Maximum fetch interval [default: 43200]
Expand Down
16 changes: 12 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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()
Expand Down

0 comments on commit 7aedf14

Please sign in to comment.