mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-24 23:57:38 +01:00
Deprecate Bot::{from_env_with_client, new, with_client}
This commit is contained in:
parent
dd880e8dac
commit
5a73654e13
1 changed files with 14 additions and 3 deletions
|
@ -30,6 +30,7 @@ impl Bot {
|
||||||
/// If cannot get the `TELOXIDE_TOKEN` environmental variable.
|
/// If cannot get the `TELOXIDE_TOKEN` environmental variable.
|
||||||
///
|
///
|
||||||
/// [`reqwest::Client`]: https://docs.rs/reqwest/0.10.1/reqwest/struct.Client.html
|
/// [`reqwest::Client`]: https://docs.rs/reqwest/0.10.1/reqwest/struct.Client.html
|
||||||
|
#[deprecated]
|
||||||
pub fn from_env_with_client(client: Client) -> Arc<Self> {
|
pub fn from_env_with_client(client: Client) -> Arc<Self> {
|
||||||
Self::with_client(
|
Self::with_client(
|
||||||
&std::env::var("TELOXIDE_TOKEN")
|
&std::env::var("TELOXIDE_TOKEN")
|
||||||
|
@ -42,6 +43,7 @@ impl Bot {
|
||||||
/// [`reqwest::Client`].
|
/// [`reqwest::Client`].
|
||||||
///
|
///
|
||||||
/// [`reqwest::Client`]: https://docs.rs/reqwest/0.10.1/reqwest/struct.Client.html
|
/// [`reqwest::Client`]: https://docs.rs/reqwest/0.10.1/reqwest/struct.Client.html
|
||||||
|
#[deprecated]
|
||||||
pub fn new<S>(token: S) -> Arc<Self>
|
pub fn new<S>(token: S) -> Arc<Self>
|
||||||
where
|
where
|
||||||
S: Into<String>,
|
S: Into<String>,
|
||||||
|
@ -53,6 +55,7 @@ impl Bot {
|
||||||
/// [`reqwest::Client`].
|
/// [`reqwest::Client`].
|
||||||
///
|
///
|
||||||
/// [`reqwest::Client`]: https://docs.rs/reqwest/0.10.1/reqwest/struct.Client.html
|
/// [`reqwest::Client`]: https://docs.rs/reqwest/0.10.1/reqwest/struct.Client.html
|
||||||
|
#[deprecated]
|
||||||
pub fn with_client<S>(token: S, client: Client) -> Arc<Self>
|
pub fn with_client<S>(token: S, client: Client) -> Arc<Self>
|
||||||
where
|
where
|
||||||
S: Into<String>,
|
S: Into<String>,
|
||||||
|
@ -92,14 +95,22 @@ impl BotBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn token(mut self, token: S) -> Self where S: Into<String> {
|
pub fn token(mut self, token: S) -> Self
|
||||||
|
where
|
||||||
|
S: Into<String>,
|
||||||
|
{
|
||||||
self.token = Some(token.into());
|
self.token = Some(token.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn build(self) -> Bot {
|
pub fn build(self) -> Bot {
|
||||||
Bot { client: self.client.unwrap_or(Client::new()), token: self.token.unwrap_or(std::env::var("TELOXIDE_TOKEN")
|
Bot {
|
||||||
.expect("Cannot get the TELOXIDE_TOKEN env variable"))}
|
client: self.client.unwrap_or(Client::new()),
|
||||||
|
token: self.token.unwrap_or(
|
||||||
|
std::env::var("TELOXIDE_TOKEN")
|
||||||
|
.expect("Cannot get the TELOXIDE_TOKEN env variable"),
|
||||||
|
),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue