Use sound_bot in client_from_env

This commit is contained in:
Temirkhan Myrzamadi 2020-07-25 03:57:38 +06:00
parent aa0b2c7d1e
commit 0fae235597

View file

@ -1,10 +1,17 @@
use crate::bot::sound_bot;
/// Constructs a client from the `TELOXIDE_PROXY` environmental variable. /// Constructs a client from the `TELOXIDE_PROXY` environmental variable.
/// ///
/// This function passes the value of `TELOXIDE_PROXY` into /// This function passes the value of `TELOXIDE_PROXY` into
/// [`reqwest::Proxy::all`], if it exists, otherwise returns the default /// [`reqwest::Proxy::all`], if it exists, otherwise returns the default
/// client. /// client.
/// ///
/// # Note
/// The created client will have safe settings, meaning that it will be able to
/// work in long time durations, see the [issue 223].
///
/// [`reqwest::Proxy::all`]: https://docs.rs/reqwest/latest/reqwest/struct.Proxy.html#method.all /// [`reqwest::Proxy::all`]: https://docs.rs/reqwest/latest/reqwest/struct.Proxy.html#method.all
/// [issue 223]: https://github.com/teloxide/teloxide/issues/223
pub fn client_from_env() -> reqwest::Client { pub fn client_from_env() -> reqwest::Client {
use reqwest::{Client, Proxy}; use reqwest::{Client, Proxy};
@ -13,6 +20,8 @@ pub fn client_from_env() -> reqwest::Client {
.proxy(Proxy::all(&proxy).expect("creating reqwest::Proxy")) .proxy(Proxy::all(&proxy).expect("creating reqwest::Proxy"))
.build() .build()
.expect("creating reqwest::Client"), .expect("creating reqwest::Client"),
None => Client::new(), None => sound_bot(),
} }
.build()
.expect("creating reqwest::Client")
} }