27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
impl Core {
pub fn new(settings: config::Config) -> Result<Arc<Core>> {
let owner = settings.get_int("owner")?;
let api_key = settings.get_string("api_key")?;
let tg = telegram_bot::Api::new(api_key);
let tg_cloned = tg.clone();
let proxy = settings.get_string("proxy")?;
let mut client = reqwest::Client::builder();
if !proxy.is_empty() {
let proxy = reqwest::Proxy::all(proxy)?;
client = client.proxy(proxy);
}
let http_client = client.build()?;
let core = Arc::new(Core {
tg,
my: task::block_on(async {
|
<
|
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
impl Core {
pub fn new(settings: config::Config) -> Result<Arc<Core>> {
let owner = settings.get_int("owner")?;
let api_key = settings.get_string("api_key")?;
let tg = telegram_bot::Api::new(api_key);
let tg_cloned = tg.clone();
let mut client = reqwest::Client::builder();
if let Ok(proxy) = settings.get_string("proxy") {
let proxy = reqwest::Proxy::all(proxy)?;
client = client.proxy(proxy);
}
let http_client = client.build()?;
let core = Arc::new(Core {
tg,
my: task::block_on(async {
|