Extract Bot from Arc

This commit is contained in:
Temirkhan Myrzamadi 2020-07-17 16:04:25 +06:00
parent 57d120b399
commit 23aa260d68
73 changed files with 334 additions and 512 deletions

View file

@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Now methods which can send file to Telegram returns tokio::io::Result<T>. Early its could panic. ([issue 216](https://github.com/teloxide/teloxide/issues/216)) - Now methods which can send file to Telegram returns tokio::io::Result<T>. Early its could panic. ([issue 216](https://github.com/teloxide/teloxide/issues/216))
- Now provided description of unknown telegram error, by splitting ApiErrorKind at `ApiErrorKind` and `ApiErrorKindKnown` enums. ([issue 199](https://github.com/teloxide/teloxide/issues/199)) - Now provided description of unknown telegram error, by splitting ApiErrorKind at `ApiErrorKind` and `ApiErrorKindKnown` enums. ([issue 199](https://github.com/teloxide/teloxide/issues/199))
- Extract `Bot` from `Arc` ([issue 216](https://github.com/teloxide/teloxide/issues/230)).
## [0.2.0] - 2020-02-25 ## [0.2.0] - 2020-02-25
### Added ### Added
- The functionality to parse commands only with a correct bot's name (breaks backwards compatibility) ([Issue 168](https://github.com/teloxide/teloxide/issues/168)). - The functionality to parse commands only with a correct bot's name (breaks backwards compatibility) ([Issue 168](https://github.com/teloxide/teloxide/issues/168)).

View file

@ -3,7 +3,7 @@
use teloxide::{dispatching::update_listeners, prelude::*}; use teloxide::{dispatching::update_listeners, prelude::*};
use std::{convert::Infallible, env, net::SocketAddr, sync::Arc}; use std::{convert::Infallible, env, net::SocketAddr};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use warp::Filter; use warp::Filter;
@ -22,7 +22,7 @@ async fn handle_rejection(
} }
pub async fn webhook<'a>( pub async fn webhook<'a>(
bot: Arc<Bot>, bot: Bot,
) -> impl update_listeners::UpdateListener<Infallible> { ) -> impl update_listeners::UpdateListener<Infallible> {
// Heroku defines auto defines a port value // Heroku defines auto defines a port value
let teloxide_token = env::var("TELOXIDE_TOKEN") let teloxide_token = env::var("TELOXIDE_TOKEN")
@ -79,7 +79,7 @@ async fn run() {
let bot = Bot::from_env(); let bot = Bot::from_env();
Dispatcher::new(Arc::clone(&bot)) Dispatcher::new(bot.clone())
.messages_handler(|rx: DispatcherHandlerRx<Message>| { .messages_handler(|rx: DispatcherHandlerRx<Message>| {
rx.for_each(|message| async move { rx.for_each(|message| async move {
message.answer_str("pong").await.log_on_error().await; message.answer_str("pong").await.log_on_error().await;

View file

@ -3,7 +3,7 @@
use teloxide::{dispatching::update_listeners, prelude::*}; use teloxide::{dispatching::update_listeners, prelude::*};
use std::{convert::Infallible, net::SocketAddr, sync::Arc}; use std::{convert::Infallible, net::SocketAddr};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use warp::Filter; use warp::Filter;
@ -22,7 +22,7 @@ async fn handle_rejection(
} }
pub async fn webhook<'a>( pub async fn webhook<'a>(
bot: Arc<Bot>, bot: Bot,
) -> impl update_listeners::UpdateListener<Infallible> { ) -> impl update_listeners::UpdateListener<Infallible> {
// You might want to specify a self-signed certificate via .certificate // You might want to specify a self-signed certificate via .certificate
// method on SetWebhook. // method on SetWebhook.
@ -60,7 +60,7 @@ async fn run() {
let bot = Bot::from_env(); let bot = Bot::from_env();
Dispatcher::new(Arc::clone(&bot)) Dispatcher::new(bot.clone())
.messages_handler(|rx: DispatcherHandlerRx<Message>| { .messages_handler(|rx: DispatcherHandlerRx<Message>| {
rx.for_each(|message| async move { rx.for_each(|message| async move {
message.answer_str("pong").await.log_on_error().await; message.answer_str("pong").await.log_on_error().await;

File diff suppressed because it is too large Load diff

View file

@ -6,11 +6,13 @@ mod api;
mod download; mod download;
/// A Telegram bot used to send requests. /// A Telegram bot used to send requests.
///
/// No need to put `Bot` into `Arc`, because it's already in.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Bot { pub struct Bot {
token: String, token: Arc<str>,
client: Client, client: Client,
parse_mode: Option<ParseMode>, parse_mode: Arc<Option<ParseMode>>,
} }
impl Bot { impl Bot {
@ -22,7 +24,7 @@ impl Bot {
/// ///
/// [`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
#[allow(deprecated)] #[allow(deprecated)]
pub fn from_env() -> Arc<Self> { pub fn from_env() -> Self {
Self::from_env_with_client(Client::new()) Self::from_env_with_client(Client::new())
} }
@ -35,7 +37,7 @@ impl Bot {
/// [`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] #[deprecated]
#[allow(deprecated)] #[allow(deprecated)]
pub fn from_env_with_client(client: Client) -> Arc<Self> { pub fn from_env_with_client(client: Client) -> Self {
Self::with_client( Self::with_client(
&std::env::var("TELOXIDE_TOKEN") &std::env::var("TELOXIDE_TOKEN")
.expect("Cannot get the TELOXIDE_TOKEN env variable"), .expect("Cannot get the TELOXIDE_TOKEN env variable"),
@ -49,7 +51,7 @@ impl Bot {
/// [`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] #[deprecated]
#[allow(deprecated)] #[allow(deprecated)]
pub fn new<S>(token: S) -> Arc<Self> pub fn new<S>(token: S) -> Self
where where
S: Into<String>, S: Into<String>,
{ {
@ -62,11 +64,15 @@ impl Bot {
/// [`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] #[deprecated]
#[allow(deprecated)] #[allow(deprecated)]
pub fn with_client<S>(token: S, client: Client) -> Arc<Self> pub fn with_client<S>(token: S, client: Client) -> Self
where where
S: Into<String>, S: Into<String>,
{ {
Arc::new(Self { token: token.into(), client, parse_mode: None }) Self {
token: Into::<Arc<str>>::into(Into::<String>::into(token)),
client,
parse_mode: Arc::new(None),
}
} }
} }
@ -156,11 +162,14 @@ impl BotBuilder {
pub fn build(self) -> Bot { pub fn build(self) -> Bot {
Bot { Bot {
client: self.client.unwrap_or_default(), client: self.client.unwrap_or_default(),
token: self.token.unwrap_or_else(|| { token: self
std::env::var("TELOXIDE_TOKEN") .token
.expect("Cannot get the TELOXIDE_TOKEN env variable") .unwrap_or_else(|| {
}), std::env::var("TELOXIDE_TOKEN")
parse_mode: self.parse_mode, .expect("Cannot get the TELOXIDE_TOKEN env variable")
})
.into(),
parse_mode: Arc::new(self.parse_mode),
} }
} }
} }

View file

@ -27,7 +27,7 @@ mod macros {
} }
fn send<'a, Upd>( fn send<'a, Upd>(
bot: &'a Arc<Bot>, bot: &'a Bot,
tx: &'a Tx<Upd>, tx: &'a Tx<Upd>,
update: Upd, update: Upd,
variant: &'static str, variant: &'static str,
@ -35,9 +35,7 @@ fn send<'a, Upd>(
Upd: Debug, Upd: Debug,
{ {
if let Some(tx) = tx { if let Some(tx) = tx {
if let Err(error) = if let Err(error) = tx.send(UpdateWithCx { bot: bot.clone(), update }) {
tx.send(UpdateWithCx { bot: Arc::clone(&bot), update })
{
log::error!( log::error!(
"The RX part of the {} channel is closed, but an update is \ "The RX part of the {} channel is closed, but an update is \
received.\nError:{}\n", received.\nError:{}\n",
@ -53,7 +51,7 @@ fn send<'a, Upd>(
/// See [the module-level documentation for the design /// See [the module-level documentation for the design
/// overview](crate::dispatching). /// overview](crate::dispatching).
pub struct Dispatcher { pub struct Dispatcher {
bot: Arc<Bot>, bot: Bot,
messages_queue: Tx<Message>, messages_queue: Tx<Message>,
edited_messages_queue: Tx<Message>, edited_messages_queue: Tx<Message>,
@ -71,7 +69,7 @@ pub struct Dispatcher {
impl Dispatcher { impl Dispatcher {
/// Constructs a new dispatcher with the specified `bot`. /// Constructs a new dispatcher with the specified `bot`.
#[must_use] #[must_use]
pub fn new(bot: Arc<Bot>) -> Self { pub fn new(bot: Bot) -> Self {
Self { Self {
bot, bot,
messages_queue: None, messages_queue: None,
@ -207,7 +205,7 @@ impl Dispatcher {
/// errors produced by this listener). /// errors produced by this listener).
pub async fn dispatch(&self) { pub async fn dispatch(&self) {
self.dispatch_with_listener( self.dispatch_with_listener(
update_listeners::polling_default(Arc::clone(&self.bot)), update_listeners::polling_default(self.bot.clone()),
LoggingErrorHandler::with_custom_text( LoggingErrorHandler::with_custom_text(
"An error from the update listener", "An error from the update listener",
), ),

View file

@ -112,7 +112,7 @@ use crate::{
RequestError, RequestError,
}; };
use std::{convert::TryInto, sync::Arc, time::Duration}; use std::{convert::TryInto, time::Duration};
/// A generic update listener. /// A generic update listener.
pub trait UpdateListener<E>: Stream<Item = Result<Update, E>> { pub trait UpdateListener<E>: Stream<Item = Result<Update, E>> {
@ -123,7 +123,7 @@ impl<S, E> UpdateListener<E> for S where S: Stream<Item = Result<Update, E>> {}
/// Returns a long polling update listener with `timeout` of 1 minute. /// Returns a long polling update listener with `timeout` of 1 minute.
/// ///
/// See also: [`polling`](polling). /// See also: [`polling`](polling).
pub fn polling_default(bot: Arc<Bot>) -> impl UpdateListener<RequestError> { pub fn polling_default(bot: Bot) -> impl UpdateListener<RequestError> {
polling(bot, Some(Duration::from_secs(60)), None, None) polling(bot, Some(Duration::from_secs(60)), None, None)
} }
@ -140,7 +140,7 @@ pub fn polling_default(bot: Arc<Bot>) -> impl UpdateListener<RequestError> {
/// ///
/// [`GetUpdates`]: crate::requests::GetUpdates /// [`GetUpdates`]: crate::requests::GetUpdates
pub fn polling( pub fn polling(
bot: Arc<Bot>, bot: Bot,
timeout: Option<Duration>, timeout: Option<Duration>,
limit: Option<u8>, limit: Option<u8>,
allowed_updates: Option<Vec<AllowedUpdate>>, allowed_updates: Option<Vec<AllowedUpdate>>,

View file

@ -9,7 +9,6 @@ use crate::{
types::{ChatId, ChatOrInlineMessage, InputFile, InputMedia, Message}, types::{ChatId, ChatOrInlineMessage, InputFile, InputMedia, Message},
Bot, Bot,
}; };
use std::sync::Arc;
/// A [`Dispatcher`]'s handler's context of a bot and an update. /// A [`Dispatcher`]'s handler's context of a bot and an update.
/// ///
@ -19,7 +18,7 @@ use std::sync::Arc;
/// [`Dispatcher`]: crate::dispatching::Dispatcher /// [`Dispatcher`]: crate::dispatching::Dispatcher
#[derive(Debug)] #[derive(Debug)]
pub struct UpdateWithCx<Upd> { pub struct UpdateWithCx<Upd> {
pub bot: Arc<Bot>, pub bot: Bot,
pub update: Upd, pub update: Upd,
} }

View file

@ -6,14 +6,13 @@ use crate::{
}; };
use crate::requests::{RequestWithFile, ResponseResult}; use crate::requests::{RequestWithFile, ResponseResult};
use std::sync::Arc;
/// Use this method to add a new sticker to a set created by the bot. /// Use this method to add a new sticker to a set created by the bot.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#addstickertoset). /// [The official docs](https://core.telegram.org/bots/api#addstickertoset).
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct AddStickerToSet { pub struct AddStickerToSet {
bot: Arc<Bot>, bot: Bot,
user_id: i32, user_id: i32,
name: String, name: String,
png_sticker: InputFile, png_sticker: InputFile,
@ -45,7 +44,7 @@ impl RequestWithFile for AddStickerToSet {
impl AddStickerToSet { impl AddStickerToSet {
pub(crate) fn new<N, E>( pub(crate) fn new<N, E>(
bot: Arc<Bot>, bot: Bot,
user_id: i32, user_id: i32,
name: N, name: N,
png_sticker: InputFile, png_sticker: InputFile,

View file

@ -6,7 +6,6 @@ use crate::{
types::True, types::True,
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send answers to callback queries sent from [inline /// Use this method to send answers to callback queries sent from [inline
/// keyboards]. /// keyboards].
@ -21,7 +20,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct AnswerCallbackQuery { pub struct AnswerCallbackQuery {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
callback_query_id: String, callback_query_id: String,
text: Option<String>, text: Option<String>,
show_alert: Option<bool>, show_alert: Option<bool>,
@ -45,7 +44,7 @@ impl Request for AnswerCallbackQuery {
} }
impl AnswerCallbackQuery { impl AnswerCallbackQuery {
pub(crate) fn new<C>(bot: Arc<Bot>, callback_query_id: C) -> Self pub(crate) fn new<C>(bot: Bot, callback_query_id: C) -> Self
where where
C: Into<String>, C: Into<String>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{InlineQueryResult, True}, types::{InlineQueryResult, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send answers to an inline query. /// Use this method to send answers to an inline query.
/// ///
@ -17,7 +16,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct AnswerInlineQuery { pub struct AnswerInlineQuery {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
inline_query_id: String, inline_query_id: String,
results: Vec<InlineQueryResult>, results: Vec<InlineQueryResult>,
cache_time: Option<i32>, cache_time: Option<i32>,
@ -43,11 +42,7 @@ impl Request for AnswerInlineQuery {
} }
impl AnswerInlineQuery { impl AnswerInlineQuery {
pub(crate) fn new<I, R>( pub(crate) fn new<I, R>(bot: Bot, inline_query_id: I, results: R) -> Self
bot: Arc<Bot>,
inline_query_id: I,
results: R,
) -> Self
where where
I: Into<String>, I: Into<String>,
R: Into<Vec<InlineQueryResult>>, R: Into<Vec<InlineQueryResult>>,

View file

@ -6,7 +6,6 @@ use crate::{
types::True, types::True,
Bot, Bot,
}; };
use std::sync::Arc;
/// Once the user has confirmed their payment and shipping details, the Bot API /// Once the user has confirmed their payment and shipping details, the Bot API
/// sends the final confirmation in the form of an [`Update`] with the field /// sends the final confirmation in the form of an [`Update`] with the field
@ -21,7 +20,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct AnswerPreCheckoutQuery { pub struct AnswerPreCheckoutQuery {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
pre_checkout_query_id: String, pre_checkout_query_id: String,
ok: bool, ok: bool,
error_message: Option<String>, error_message: Option<String>,
@ -43,11 +42,7 @@ impl Request for AnswerPreCheckoutQuery {
} }
impl AnswerPreCheckoutQuery { impl AnswerPreCheckoutQuery {
pub(crate) fn new<P>( pub(crate) fn new<P>(bot: Bot, pre_checkout_query_id: P, ok: bool) -> Self
bot: Arc<Bot>,
pre_checkout_query_id: P,
ok: bool,
) -> Self
where where
P: Into<String>, P: Into<String>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ShippingOption, True}, types::{ShippingOption, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// If you sent an invoice requesting a shipping address and the parameter /// If you sent an invoice requesting a shipping address and the parameter
/// `is_flexible` was specified, the Bot API will send an [`Update`] with a /// `is_flexible` was specified, the Bot API will send an [`Update`] with a
@ -20,7 +19,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct AnswerShippingQuery { pub struct AnswerShippingQuery {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
shipping_query_id: String, shipping_query_id: String,
ok: bool, ok: bool,
shipping_options: Option<Vec<ShippingOption>>, shipping_options: Option<Vec<ShippingOption>>,
@ -43,7 +42,7 @@ impl Request for AnswerShippingQuery {
} }
impl AnswerShippingQuery { impl AnswerShippingQuery {
pub(crate) fn new<S>(bot: Arc<Bot>, shipping_query_id: S, ok: bool) -> Self pub(crate) fn new<S>(bot: Bot, shipping_query_id: S, ok: bool) -> Self
where where
S: Into<String>, S: Into<String>,
{ {

View file

@ -4,7 +4,6 @@ use crate::{
types::{InputFile, MaskPosition, True}, types::{InputFile, MaskPosition, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to create new sticker set owned by a user. The bot will be /// Use this method to create new sticker set owned by a user. The bot will be
/// able to edit the created sticker set. /// able to edit the created sticker set.
@ -12,7 +11,7 @@ use std::sync::Arc;
/// [The official docs](https://core.telegram.org/bots/api#createnewstickerset). /// [The official docs](https://core.telegram.org/bots/api#createnewstickerset).
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct CreateNewStickerSet { pub struct CreateNewStickerSet {
bot: Arc<Bot>, bot: Bot,
user_id: i32, user_id: i32,
name: String, name: String,
title: String, title: String,
@ -48,7 +47,7 @@ impl RequestWithFile for CreateNewStickerSet {
impl CreateNewStickerSet { impl CreateNewStickerSet {
pub(crate) fn new<N, T, E>( pub(crate) fn new<N, T, E>(
bot: Arc<Bot>, bot: Bot,
user_id: i32, user_id: i32,
name: N, name: N,
title: T, title: T,

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to delete a chat photo. Photos can't be changed for private /// Use this method to delete a chat photo. Photos can't be changed for private
/// chats. The bot must be an administrator in the chat for this to work and /// chats. The bot must be an administrator in the chat for this to work and
@ -17,7 +16,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct DeleteChatPhoto { pub struct DeleteChatPhoto {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
} }
@ -37,7 +36,7 @@ impl Request for DeleteChatPhoto {
} }
impl DeleteChatPhoto { impl DeleteChatPhoto {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to delete a group sticker set from a supergroup. /// Use this method to delete a group sticker set from a supergroup.
/// ///
@ -22,7 +21,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct DeleteChatStickerSet { pub struct DeleteChatStickerSet {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
} }
@ -42,7 +41,7 @@ impl Request for DeleteChatStickerSet {
} }
impl DeleteChatStickerSet { impl DeleteChatStickerSet {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to delete a message, including service messages. /// Use this method to delete a message, including service messages.
/// ///
@ -27,7 +26,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct DeleteMessage { pub struct DeleteMessage {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
message_id: i32, message_id: i32,
} }
@ -48,7 +47,7 @@ impl Request for DeleteMessage {
} }
impl DeleteMessage { impl DeleteMessage {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, message_id: i32) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, message_id: i32) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::True, types::True,
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to delete a sticker from a set created by the bot. /// Use this method to delete a sticker from a set created by the bot.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct DeleteStickerFromSet { pub struct DeleteStickerFromSet {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
sticker: String, sticker: String,
} }
@ -35,7 +34,7 @@ impl Request for DeleteStickerFromSet {
} }
impl DeleteStickerFromSet { impl DeleteStickerFromSet {
pub(crate) fn new<S>(bot: Arc<Bot>, sticker: S) -> Self pub(crate) fn new<S>(bot: Bot, sticker: S) -> Self
where where
S: Into<String>, S: Into<String>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::True, types::True,
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to remove webhook integration if you decide to switch back /// Use this method to remove webhook integration if you decide to switch back
/// to [Bot::get_updates]. /// to [Bot::get_updates].
@ -18,7 +17,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct DeleteWebhook { pub struct DeleteWebhook {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
} }
#[async_trait::async_trait] #[async_trait::async_trait]
@ -38,7 +37,7 @@ impl Request for DeleteWebhook {
} }
impl DeleteWebhook { impl DeleteWebhook {
pub(crate) fn new(bot: Arc<Bot>) -> Self { pub(crate) fn new(bot: Bot) -> Self {
Self { bot } Self { bot }
} }
} }

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to edit captions of messages. /// Use this method to edit captions of messages.
/// ///
@ -21,7 +20,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct EditMessageCaption { pub struct EditMessageCaption {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
#[serde(flatten)] #[serde(flatten)]
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
caption: Option<String>, caption: Option<String>,
@ -46,7 +45,7 @@ impl Request for EditMessageCaption {
impl EditMessageCaption { impl EditMessageCaption {
pub(crate) fn new( pub(crate) fn new(
bot: Arc<Bot>, bot: Bot,
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
) -> Self { ) -> Self {
Self { Self {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to edit live location messages. /// Use this method to edit live location messages.
/// ///
@ -23,7 +22,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct EditMessageLiveLocation { pub struct EditMessageLiveLocation {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
#[serde(flatten)] #[serde(flatten)]
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
latitude: f32, latitude: f32,
@ -48,7 +47,7 @@ impl Request for EditMessageLiveLocation {
impl EditMessageLiveLocation { impl EditMessageLiveLocation {
pub(crate) fn new( pub(crate) fn new(
bot: Arc<Bot>, bot: Bot,
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
latitude: f32, latitude: f32,
longitude: f32, longitude: f32,

View file

@ -4,7 +4,6 @@ use crate::{
types::{ChatOrInlineMessage, InlineKeyboardMarkup, InputMedia, Message}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, InputMedia, Message},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to edit animation, audio, document, photo, or video /// Use this method to edit animation, audio, document, photo, or video
/// messages. /// messages.
@ -22,7 +21,7 @@ use std::sync::Arc;
/// [`True`]: crate::types::True /// [`True`]: crate::types::True
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct EditMessageMedia { pub struct EditMessageMedia {
bot: Arc<Bot>, bot: Bot,
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
media: InputMedia, media: InputMedia,
reply_markup: Option<InlineKeyboardMarkup>, reply_markup: Option<InlineKeyboardMarkup>,
@ -62,7 +61,7 @@ impl Request for EditMessageMedia {
impl EditMessageMedia { impl EditMessageMedia {
pub(crate) fn new( pub(crate) fn new(
bot: Arc<Bot>, bot: Bot,
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
media: InputMedia, media: InputMedia,
) -> Self { ) -> Self {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to edit only the reply markup of messages. /// Use this method to edit only the reply markup of messages.
/// ///
@ -21,7 +20,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct EditMessageReplyMarkup { pub struct EditMessageReplyMarkup {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
#[serde(flatten)] #[serde(flatten)]
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
reply_markup: Option<InlineKeyboardMarkup>, reply_markup: Option<InlineKeyboardMarkup>,
@ -44,7 +43,7 @@ impl Request for EditMessageReplyMarkup {
impl EditMessageReplyMarkup { impl EditMessageReplyMarkup {
pub(crate) fn new( pub(crate) fn new(
bot: Arc<Bot>, bot: Bot,
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
) -> Self { ) -> Self {
Self { bot, chat_or_inline_message, reply_markup: None } Self { bot, chat_or_inline_message, reply_markup: None }

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to edit text and game messages. /// Use this method to edit text and game messages.
/// ///
@ -21,7 +20,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct EditMessageText { pub struct EditMessageText {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
#[serde(flatten)] #[serde(flatten)]
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
text: String, text: String,
@ -47,7 +46,7 @@ impl Request for EditMessageText {
impl EditMessageText { impl EditMessageText {
pub(crate) fn new<T>( pub(crate) fn new<T>(
bot: Arc<Bot>, bot: Bot,
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
text: T, text: T,
) -> Self ) -> Self

View file

@ -6,7 +6,6 @@ use crate::{
types::ChatId, types::ChatId,
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to generate a new invite link for a chat; any previously /// Use this method to generate a new invite link for a chat; any previously
/// generated link is revoked. /// generated link is revoked.
@ -31,7 +30,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct ExportChatInviteLink { pub struct ExportChatInviteLink {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
} }
@ -52,7 +51,7 @@ impl Request for ExportChatInviteLink {
} }
impl ExportChatInviteLink { impl ExportChatInviteLink {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, Message}, types::{ChatId, Message},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to forward messages of any kind. /// Use this method to forward messages of any kind.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct ForwardMessage { pub struct ForwardMessage {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
from_chat_id: ChatId, from_chat_id: ChatId,
disable_notification: Option<bool>, disable_notification: Option<bool>,
@ -39,7 +38,7 @@ impl Request for ForwardMessage {
impl ForwardMessage { impl ForwardMessage {
pub(crate) fn new<C, F>( pub(crate) fn new<C, F>(
bot: Arc<Bot>, bot: Bot,
chat_id: C, chat_id: C,
from_chat_id: F, from_chat_id: F,
message_id: i32, message_id: i32,

View file

@ -6,7 +6,6 @@ use crate::{
types::{Chat, ChatId}, types::{Chat, ChatId},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to get up to date information about the chat (current name /// Use this method to get up to date information about the chat (current name
/// of the user for one-on-one conversations, current username of a user, group /// of the user for one-on-one conversations, current username of a user, group
@ -17,7 +16,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct GetChat { pub struct GetChat {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
} }
@ -32,7 +31,7 @@ impl Request for GetChat {
} }
impl GetChat { impl GetChat {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, ChatMember}, types::{ChatId, ChatMember},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to get a list of administrators in a chat. /// Use this method to get a list of administrators in a chat.
/// ///
@ -18,7 +17,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct GetChatAdministrators { pub struct GetChatAdministrators {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
} }
@ -40,7 +39,7 @@ impl Request for GetChatAdministrators {
} }
impl GetChatAdministrators { impl GetChatAdministrators {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, ChatMember}, types::{ChatId, ChatMember},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to get information about a member of a chat. /// Use this method to get information about a member of a chat.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct GetChatMember { pub struct GetChatMember {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
user_id: i32, user_id: i32,
} }
@ -36,7 +35,7 @@ impl Request for GetChatMember {
} }
impl GetChatMember { impl GetChatMember {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, user_id: i32) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, user_id: i32) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::ChatId, types::ChatId,
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to get the number of members in a chat. /// Use this method to get the number of members in a chat.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct GetChatMembersCount { pub struct GetChatMembersCount {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
} }
@ -35,7 +34,7 @@ impl Request for GetChatMembersCount {
} }
impl GetChatMembersCount { impl GetChatMembersCount {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::File, types::File,
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to get basic info about a file and prepare it for /// Use this method to get basic info about a file and prepare it for
/// downloading. /// downloading.
@ -31,7 +30,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct GetFile { pub struct GetFile {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
file_id: String, file_id: String,
} }
@ -46,7 +45,7 @@ impl Request for GetFile {
} }
impl GetFile { impl GetFile {
pub(crate) fn new<F>(bot: Arc<Bot>, file_id: F) -> Self pub(crate) fn new<F>(bot: Bot, file_id: F) -> Self
where where
F: Into<String>, F: Into<String>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatOrInlineMessage, GameHighScore}, types::{ChatOrInlineMessage, GameHighScore},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to get data for high score tables. /// Use this method to get data for high score tables.
/// ///
@ -24,7 +23,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct GetGameHighScores { pub struct GetGameHighScores {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
#[serde(flatten)] #[serde(flatten)]
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
user_id: i32, user_id: i32,
@ -47,7 +46,7 @@ impl Request for GetGameHighScores {
impl GetGameHighScores { impl GetGameHighScores {
pub(crate) fn new( pub(crate) fn new(
bot: Arc<Bot>, bot: Bot,
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
user_id: i32, user_id: i32,
) -> Self { ) -> Self {

View file

@ -5,7 +5,6 @@ use crate::{
Bot, Bot,
}; };
use serde::Serialize; use serde::Serialize;
use std::sync::Arc;
/// A simple method for testing your bot's auth token. Requires no parameters. /// A simple method for testing your bot's auth token. Requires no parameters.
/// ///
@ -13,7 +12,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct GetMe { pub struct GetMe {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
} }
#[async_trait::async_trait] #[async_trait::async_trait]
@ -29,7 +28,7 @@ impl Request for GetMe {
} }
impl GetMe { impl GetMe {
pub(crate) fn new(bot: Arc<Bot>) -> Self { pub(crate) fn new(bot: Bot) -> Self {
Self { bot } Self { bot }
} }
} }

View file

@ -6,7 +6,6 @@ use crate::{
types::StickerSet, types::StickerSet,
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to get a sticker set. /// Use this method to get a sticker set.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct GetStickerSet { pub struct GetStickerSet {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
name: String, name: String,
} }
@ -35,7 +34,7 @@ impl Request for GetStickerSet {
} }
impl GetStickerSet { impl GetStickerSet {
pub(crate) fn new<N>(bot: Arc<Bot>, name: N) -> Self pub(crate) fn new<N>(bot: Bot, name: N) -> Self
where where
N: Into<String>, N: Into<String>,
{ {

View file

@ -7,7 +7,6 @@ use crate::{
Bot, RequestError, Bot, RequestError,
}; };
use serde_json::Value; use serde_json::Value;
use std::sync::Arc;
/// Use this method to receive incoming updates using long polling ([wiki]). /// Use this method to receive incoming updates using long polling ([wiki]).
/// ///
@ -23,7 +22,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct GetUpdates { pub struct GetUpdates {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
pub(crate) offset: Option<i32>, pub(crate) offset: Option<i32>,
pub(crate) limit: Option<u8>, pub(crate) limit: Option<u8>,
pub(crate) timeout: Option<u32>, pub(crate) timeout: Option<u32>,
@ -64,7 +63,7 @@ impl Request for GetUpdates {
} }
impl GetUpdates { impl GetUpdates {
pub(crate) fn new(bot: Arc<Bot>) -> Self { pub(crate) fn new(bot: Bot) -> Self {
Self { Self {
bot, bot,
offset: None, offset: None,

View file

@ -6,7 +6,6 @@ use crate::{
types::UserProfilePhotos, types::UserProfilePhotos,
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to get a list of profile pictures for a user. /// Use this method to get a list of profile pictures for a user.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct GetUserProfilePhotos { pub struct GetUserProfilePhotos {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
user_id: i32, user_id: i32,
offset: Option<i32>, offset: Option<i32>,
limit: Option<i32>, limit: Option<i32>,
@ -37,7 +36,7 @@ impl Request for GetUserProfilePhotos {
} }
impl GetUserProfilePhotos { impl GetUserProfilePhotos {
pub(crate) fn new(bot: Arc<Bot>, user_id: i32) -> Self { pub(crate) fn new(bot: Bot, user_id: i32) -> Self {
Self { bot, user_id, offset: None, limit: None } Self { bot, user_id, offset: None, limit: None }
} }

View file

@ -6,7 +6,6 @@ use crate::{
types::WebhookInfo, types::WebhookInfo,
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to get current webhook status. /// Use this method to get current webhook status.
/// ///
@ -19,7 +18,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct GetWebhookInfo { pub struct GetWebhookInfo {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
} }
#[async_trait::async_trait] #[async_trait::async_trait]
@ -39,7 +38,7 @@ impl Request for GetWebhookInfo {
} }
impl GetWebhookInfo { impl GetWebhookInfo {
pub(crate) fn new(bot: Arc<Bot>) -> Self { pub(crate) fn new(bot: Bot) -> Self {
Self { bot } Self { bot }
} }
} }

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to kick a user from a group, a supergroup or a channel. /// Use this method to kick a user from a group, a supergroup or a channel.
/// ///
@ -22,7 +21,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct KickChatMember { pub struct KickChatMember {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
user_id: i32, user_id: i32,
until_date: Option<i32>, until_date: Option<i32>,
@ -44,7 +43,7 @@ impl Request for KickChatMember {
} }
impl KickChatMember { impl KickChatMember {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, user_id: i32) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, user_id: i32) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method for your bot to leave a group, supergroup or channel. /// Use this method for your bot to leave a group, supergroup or channel.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct LeaveChat { pub struct LeaveChat {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
} }
@ -35,7 +34,7 @@ impl Request for LeaveChat {
} }
impl LeaveChat { impl LeaveChat {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to pin a message in a group, a supergroup, or a channel. /// Use this method to pin a message in a group, a supergroup, or a channel.
/// ///
@ -19,7 +18,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct PinChatMessage { pub struct PinChatMessage {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
message_id: i32, message_id: i32,
disable_notification: Option<bool>, disable_notification: Option<bool>,
@ -41,7 +40,7 @@ impl Request for PinChatMessage {
} }
impl PinChatMessage { impl PinChatMessage {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, message_id: i32) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, message_id: i32) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to promote or demote a user in a supergroup or a channel. /// Use this method to promote or demote a user in a supergroup or a channel.
/// ///
@ -19,7 +18,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct PromoteChatMember { pub struct PromoteChatMember {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
user_id: i32, user_id: i32,
can_change_info: Option<bool>, can_change_info: Option<bool>,
@ -48,7 +47,7 @@ impl Request for PromoteChatMember {
} }
impl PromoteChatMember { impl PromoteChatMember {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, user_id: i32) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, user_id: i32) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, ChatPermissions, True}, types::{ChatId, ChatPermissions, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to restrict a user in a supergroup. /// Use this method to restrict a user in a supergroup.
/// ///
@ -19,7 +18,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct RestrictChatMember { pub struct RestrictChatMember {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
user_id: i32, user_id: i32,
permissions: ChatPermissions, permissions: ChatPermissions,
@ -43,7 +42,7 @@ impl Request for RestrictChatMember {
impl RestrictChatMember { impl RestrictChatMember {
pub(crate) fn new<C>( pub(crate) fn new<C>(
bot: Arc<Bot>, bot: Bot,
chat_id: C, chat_id: C,
user_id: i32, user_id: i32,
permissions: ChatPermissions, permissions: ChatPermissions,

View file

@ -4,7 +4,6 @@ use crate::{
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send animation files (GIF or H.264/MPEG-4 AVC video /// Use this method to send animation files (GIF or H.264/MPEG-4 AVC video
/// without sound). /// without sound).
@ -15,7 +14,7 @@ use std::sync::Arc;
/// [The official docs](https://core.telegram.org/bots/api#sendanimation). /// [The official docs](https://core.telegram.org/bots/api#sendanimation).
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SendAnimation { pub struct SendAnimation {
bot: Arc<Bot>, bot: Bot,
pub chat_id: ChatId, pub chat_id: ChatId,
pub animation: InputFile, pub animation: InputFile,
pub duration: Option<u32>, pub duration: Option<u32>,
@ -60,11 +59,7 @@ impl RequestWithFile for SendAnimation {
} }
impl SendAnimation { impl SendAnimation {
pub(crate) fn new<C>( pub(crate) fn new<C>(bot: Bot, chat_id: C, animation: InputFile) -> Self
bot: Arc<Bot>,
chat_id: C,
animation: InputFile,
) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -4,7 +4,6 @@ use crate::{
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send audio files, if you want Telegram clients to display /// Use this method to send audio files, if you want Telegram clients to display
/// them in the music player. /// them in the music player.
@ -19,7 +18,7 @@ use std::sync::Arc;
/// [`Bot::send_voice`]: crate::Bot::send_voice /// [`Bot::send_voice`]: crate::Bot::send_voice
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SendAudio { pub struct SendAudio {
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
audio: InputFile, audio: InputFile,
caption: Option<String>, caption: Option<String>,
@ -64,7 +63,7 @@ impl RequestWithFile for SendAudio {
} }
impl SendAudio { impl SendAudio {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, audio: InputFile) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, audio: InputFile) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method when you need to tell the user that something is happening /// Use this method when you need to tell the user that something is happening
/// on the bot's side. /// on the bot's side.
@ -29,7 +28,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SendChatAction { pub struct SendChatAction {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
action: SendChatActionKind, action: SendChatActionKind,
} }
@ -88,7 +87,7 @@ impl Request for SendChatAction {
impl SendChatAction { impl SendChatAction {
pub(crate) fn new<C>( pub(crate) fn new<C>(
bot: Arc<Bot>, bot: Bot,
chat_id: C, chat_id: C,
action: SendChatActionKind, action: SendChatActionKind,
) -> Self ) -> Self

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, Message, ReplyMarkup}, types::{ChatId, Message, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send phone contacts. /// Use this method to send phone contacts.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SendContact { pub struct SendContact {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
phone_number: String, phone_number: String,
first_name: String, first_name: String,
@ -43,7 +42,7 @@ impl Request for SendContact {
impl SendContact { impl SendContact {
pub(crate) fn new<C, P, F>( pub(crate) fn new<C, P, F>(
bot: Arc<Bot>, bot: Bot,
chat_id: C, chat_id: C,
phone_number: P, phone_number: P,
first_name: F, first_name: F,

View file

@ -4,7 +4,6 @@ use crate::{
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send general files. /// Use this method to send general files.
/// ///
@ -14,7 +13,7 @@ use std::sync::Arc;
/// [The official docs](https://core.telegram.org/bots/api#senddocument). /// [The official docs](https://core.telegram.org/bots/api#senddocument).
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SendDocument { pub struct SendDocument {
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
document: InputFile, document: InputFile,
thumb: Option<InputFile>, thumb: Option<InputFile>,
@ -53,7 +52,7 @@ impl RequestWithFile for SendDocument {
} }
impl SendDocument { impl SendDocument {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, document: InputFile) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, document: InputFile) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{InlineKeyboardMarkup, Message}, types::{InlineKeyboardMarkup, Message},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send a game. /// Use this method to send a game.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SendGame { pub struct SendGame {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: i32, chat_id: i32,
game_short_name: String, game_short_name: String,
disable_notification: Option<bool>, disable_notification: Option<bool>,
@ -39,11 +38,7 @@ impl Request for SendGame {
} }
impl SendGame { impl SendGame {
pub(crate) fn new<G>( pub(crate) fn new<G>(bot: Bot, chat_id: i32, game_short_name: G) -> Self
bot: Arc<Bot>,
chat_id: i32,
game_short_name: G,
) -> Self
where where
G: Into<String>, G: Into<String>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{InlineKeyboardMarkup, LabeledPrice, Message}, types::{InlineKeyboardMarkup, LabeledPrice, Message},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send invoices. /// Use this method to send invoices.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SendInvoice { pub struct SendInvoice {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: i32, chat_id: i32,
title: String, title: String,
description: String, description: String,
@ -59,7 +58,7 @@ impl Request for SendInvoice {
impl SendInvoice { impl SendInvoice {
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub(crate) fn new<T, D, Pl, Pt, S, C, Pr>( pub(crate) fn new<T, D, Pl, Pt, S, C, Pr>(
bot: Arc<Bot>, bot: Bot,
chat_id: i32, chat_id: i32,
title: T, title: T,
description: D, description: D,

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, Message, ReplyMarkup}, types::{ChatId, Message, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send point on the map. /// Use this method to send point on the map.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SendLocation { pub struct SendLocation {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
latitude: f32, latitude: f32,
longitude: f32, longitude: f32,
@ -42,7 +41,7 @@ impl Request for SendLocation {
impl SendLocation { impl SendLocation {
pub(crate) fn new<C>( pub(crate) fn new<C>(
bot: Arc<Bot>, bot: Bot,
chat_id: C, chat_id: C,
latitude: f32, latitude: f32,
longitude: f32, longitude: f32,

View file

@ -4,14 +4,13 @@ use crate::{
types::{ChatId, InputMedia, Message}, types::{ChatId, InputMedia, Message},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send a group of photos or videos as an album. /// Use this method to send a group of photos or videos as an album.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#sendmediagroup). /// [The official docs](https://core.telegram.org/bots/api#sendmediagroup).
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SendMediaGroup { pub struct SendMediaGroup {
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
media: Vec<InputMedia>, // TODO: InputMediaPhoto and InputMediaVideo media: Vec<InputMedia>, // TODO: InputMediaPhoto and InputMediaVideo
disable_notification: Option<bool>, disable_notification: Option<bool>,
@ -39,7 +38,7 @@ impl Request for SendMediaGroup {
} }
impl SendMediaGroup { impl SendMediaGroup {
pub(crate) fn new<C, M>(bot: Arc<Bot>, chat_id: C, media: M) -> Self pub(crate) fn new<C, M>(bot: Bot, chat_id: C, media: M) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
M: Into<Vec<InputMedia>>, M: Into<Vec<InputMedia>>,

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, Message, ParseMode, ReplyMarkup}, types::{ChatId, Message, ParseMode, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send text messages. /// Use this method to send text messages.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SendMessage { pub struct SendMessage {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
pub chat_id: ChatId, pub chat_id: ChatId,
pub text: String, pub text: String,
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
@ -41,7 +40,7 @@ impl Request for SendMessage {
} }
impl SendMessage { impl SendMessage {
pub(crate) fn new<C, T>(bot: Arc<Bot>, chat_id: C, text: T) -> Self pub(crate) fn new<C, T>(bot: Bot, chat_id: C, text: T) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
T: Into<String>, T: Into<String>,

View file

@ -4,14 +4,13 @@ use crate::{
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send photos. /// Use this method to send photos.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#sendphoto). /// [The official docs](https://core.telegram.org/bots/api#sendphoto).
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SendPhoto { pub struct SendPhoto {
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
photo: InputFile, photo: InputFile,
caption: Option<String>, caption: Option<String>,
@ -46,7 +45,7 @@ impl RequestWithFile for SendPhoto {
} }
impl SendPhoto { impl SendPhoto {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, photo: InputFile) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, photo: InputFile) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, Message, PollType, ReplyMarkup}, types::{ChatId, Message, PollType, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send a native poll. /// Use this method to send a native poll.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SendPoll { pub struct SendPoll {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
question: String, question: String,
options: Vec<String>, options: Vec<String>,
@ -46,7 +45,7 @@ impl Request for SendPoll {
impl SendPoll { impl SendPoll {
pub(crate) fn new<C, Q, O>( pub(crate) fn new<C, Q, O>(
bot: Arc<Bot>, bot: Bot,
chat_id: C, chat_id: C,
question: Q, question: Q,
options: O, options: O,

View file

@ -4,7 +4,6 @@ use crate::{
types::{ChatId, InputFile, Message, ReplyMarkup}, types::{ChatId, InputFile, Message, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send static .WEBP or [animated] .TGS stickers. /// Use this method to send static .WEBP or [animated] .TGS stickers.
/// ///
@ -13,7 +12,7 @@ use std::sync::Arc;
/// [animated]: https://telegram.org/blog/animated-stickers /// [animated]: https://telegram.org/blog/animated-stickers
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SendSticker { pub struct SendSticker {
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
sticker: InputFile, sticker: InputFile,
disable_notification: Option<bool>, disable_notification: Option<bool>,
@ -44,7 +43,7 @@ impl RequestWithFile for SendSticker {
} }
impl SendSticker { impl SendSticker {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, sticker: InputFile) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, sticker: InputFile) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, Message, ReplyMarkup}, types::{ChatId, Message, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send information about a venue. /// Use this method to send information about a venue.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SendVenue { pub struct SendVenue {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
latitude: f32, latitude: f32,
longitude: f32, longitude: f32,
@ -45,7 +44,7 @@ impl Request for SendVenue {
impl SendVenue { impl SendVenue {
pub(crate) fn new<C, T, A>( pub(crate) fn new<C, T, A>(
bot: Arc<Bot>, bot: Bot,
chat_id: C, chat_id: C,
latitude: f32, latitude: f32,
longitude: f32, longitude: f32,

View file

@ -4,7 +4,6 @@ use crate::{
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send video files, Telegram clients support mp4 videos /// Use this method to send video files, Telegram clients support mp4 videos
/// (other formats may be sent as Document). /// (other formats may be sent as Document).
@ -15,7 +14,7 @@ use std::sync::Arc;
/// [The official docs](https://core.telegram.org/bots/api#sendvideo). /// [The official docs](https://core.telegram.org/bots/api#sendvideo).
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SendVideo { pub struct SendVideo {
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
video: InputFile, video: InputFile,
duration: Option<i32>, duration: Option<i32>,
@ -62,7 +61,7 @@ impl RequestWithFile for SendVideo {
} }
impl SendVideo { impl SendVideo {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, video: InputFile) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, video: InputFile) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -4,7 +4,6 @@ use crate::{
types::{ChatId, InputFile, Message, ReplyMarkup}, types::{ChatId, InputFile, Message, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// As of [v.4.0], Telegram clients support rounded square mp4 videos of up to 1 /// As of [v.4.0], Telegram clients support rounded square mp4 videos of up to 1
/// minute long. Use this method to send video messages. /// minute long. Use this method to send video messages.
@ -14,7 +13,7 @@ use std::sync::Arc;
/// [v.4.0]: https://telegram.org/blog/video-messages-and-telescope /// [v.4.0]: https://telegram.org/blog/video-messages-and-telescope
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SendVideoNote { pub struct SendVideoNote {
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
video_note: InputFile, video_note: InputFile,
duration: Option<i32>, duration: Option<i32>,
@ -53,11 +52,7 @@ impl RequestWithFile for SendVideoNote {
} }
impl SendVideoNote { impl SendVideoNote {
pub(crate) fn new<C>( pub(crate) fn new<C>(bot: Bot, chat_id: C, video_note: InputFile) -> Self
bot: Arc<Bot>,
chat_id: C,
video_note: InputFile,
) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -4,7 +4,6 @@ use crate::{
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to send audio files, if you want Telegram clients to display /// Use this method to send audio files, if you want Telegram clients to display
/// the file as a playable voice message. /// the file as a playable voice message.
@ -20,7 +19,7 @@ use std::sync::Arc;
/// [`Document`]: crate::types::Document /// [`Document`]: crate::types::Document
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SendVoice { pub struct SendVoice {
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
voice: InputFile, voice: InputFile,
caption: Option<String>, caption: Option<String>,
@ -57,7 +56,7 @@ impl RequestWithFile for SendVoice {
} }
impl SendVoice { impl SendVoice {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, voice: InputFile) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, voice: InputFile) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to set a custom title for an administrator in a supergroup /// Use this method to set a custom title for an administrator in a supergroup
/// promoted by the bot. /// promoted by the bot.
@ -16,7 +15,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SetChatAdministratorCustomTitle { pub struct SetChatAdministratorCustomTitle {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
user_id: i32, user_id: i32,
custom_title: String, custom_title: String,
@ -39,7 +38,7 @@ impl Request for SetChatAdministratorCustomTitle {
impl SetChatAdministratorCustomTitle { impl SetChatAdministratorCustomTitle {
pub(crate) fn new<C, CT>( pub(crate) fn new<C, CT>(
bot: Arc<Bot>, bot: Bot,
chat_id: C, chat_id: C,
user_id: i32, user_id: i32,
custom_title: CT, custom_title: CT,

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to change the description of a group, a supergroup or a /// Use this method to change the description of a group, a supergroup or a
/// channel. /// channel.
@ -19,7 +18,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SetChatDescription { pub struct SetChatDescription {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
description: Option<String>, description: Option<String>,
} }
@ -40,7 +39,7 @@ impl Request for SetChatDescription {
} }
impl SetChatDescription { impl SetChatDescription {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, ChatPermissions, True}, types::{ChatId, ChatPermissions, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to set default chat permissions for all members. /// Use this method to set default chat permissions for all members.
/// ///
@ -18,7 +17,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SetChatPermissions { pub struct SetChatPermissions {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
permissions: ChatPermissions, permissions: ChatPermissions,
} }
@ -40,7 +39,7 @@ impl Request for SetChatPermissions {
impl SetChatPermissions { impl SetChatPermissions {
pub(crate) fn new<C>( pub(crate) fn new<C>(
bot: Arc<Bot>, bot: Bot,
chat_id: C, chat_id: C,
permissions: ChatPermissions, permissions: ChatPermissions,
) -> Self ) -> Self

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, InputFile, True}, types::{ChatId, InputFile, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to set a new profile photo for the chat. /// Use this method to set a new profile photo for the chat.
/// ///
@ -18,7 +17,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SetChatPhoto { pub struct SetChatPhoto {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
photo: InputFile, photo: InputFile,
} }
@ -39,7 +38,7 @@ impl Request for SetChatPhoto {
} }
impl SetChatPhoto { impl SetChatPhoto {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, photo: InputFile) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, photo: InputFile) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to set a new group sticker set for a supergroup. /// Use this method to set a new group sticker set for a supergroup.
/// ///
@ -19,7 +18,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SetChatStickerSet { pub struct SetChatStickerSet {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
sticker_set_name: String, sticker_set_name: String,
} }
@ -40,11 +39,7 @@ impl Request for SetChatStickerSet {
} }
impl SetChatStickerSet { impl SetChatStickerSet {
pub(crate) fn new<C, S>( pub(crate) fn new<C, S>(bot: Bot, chat_id: C, sticker_set_name: S) -> Self
bot: Arc<Bot>,
chat_id: C,
sticker_set_name: S,
) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
S: Into<String>, S: Into<String>,

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to change the title of a chat. /// Use this method to change the title of a chat.
/// ///
@ -18,7 +17,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SetChatTitle { pub struct SetChatTitle {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
title: String, title: String,
} }
@ -39,7 +38,7 @@ impl Request for SetChatTitle {
} }
impl SetChatTitle { impl SetChatTitle {
pub(crate) fn new<C, T>(bot: Arc<Bot>, chat_id: C, title: T) -> Self pub(crate) fn new<C, T>(bot: Bot, chat_id: C, title: T) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
T: Into<String>, T: Into<String>,

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatOrInlineMessage, Message}, types::{ChatOrInlineMessage, Message},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to set the score of the specified user in a game. /// Use this method to set the score of the specified user in a game.
/// ///
@ -23,7 +22,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SetGameScore { pub struct SetGameScore {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
#[serde(flatten)] #[serde(flatten)]
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
user_id: i32, user_id: i32,
@ -49,7 +48,7 @@ impl Request for SetGameScore {
impl SetGameScore { impl SetGameScore {
pub(crate) fn new( pub(crate) fn new(
bot: Arc<Bot>, bot: Bot,
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
user_id: i32, user_id: i32,
score: i32, score: i32,

View file

@ -6,7 +6,6 @@ use crate::{
types::True, types::True,
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to move a sticker in a set created by the bot to a specific /// Use this method to move a sticker in a set created by the bot to a specific
/// position. /// position.
@ -16,7 +15,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SetStickerPositionInSet { pub struct SetStickerPositionInSet {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
sticker: String, sticker: String,
position: i32, position: i32,
} }
@ -37,7 +36,7 @@ impl Request for SetStickerPositionInSet {
} }
impl SetStickerPositionInSet { impl SetStickerPositionInSet {
pub(crate) fn new<S>(bot: Arc<Bot>, sticker: S, position: i32) -> Self pub(crate) fn new<S>(bot: Bot, sticker: S, position: i32) -> Self
where where
S: Into<String>, S: Into<String>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{AllowedUpdate, InputFile, True}, types::{AllowedUpdate, InputFile, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to specify a url and receive incoming updates via an /// Use this method to specify a url and receive incoming updates via an
/// outgoing webhook. /// outgoing webhook.
@ -28,7 +27,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct SetWebhook { pub struct SetWebhook {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
url: String, url: String,
certificate: Option<InputFile>, certificate: Option<InputFile>,
max_connections: Option<i32>, max_connections: Option<i32>,
@ -51,7 +50,7 @@ impl Request for SetWebhook {
} }
impl SetWebhook { impl SetWebhook {
pub(crate) fn new<U>(bot: Arc<Bot>, url: U) -> Self pub(crate) fn new<U>(bot: Bot, url: U) -> Self
where where
U: Into<String>, U: Into<String>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to stop updating a live location message before /// Use this method to stop updating a live location message before
/// `live_period` expires. /// `live_period` expires.
@ -22,7 +21,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct StopMessageLiveLocation { pub struct StopMessageLiveLocation {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
#[serde(flatten)] #[serde(flatten)]
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
reply_markup: Option<InlineKeyboardMarkup>, reply_markup: Option<InlineKeyboardMarkup>,
@ -45,7 +44,7 @@ impl Request for StopMessageLiveLocation {
impl StopMessageLiveLocation { impl StopMessageLiveLocation {
pub(crate) fn new( pub(crate) fn new(
bot: Arc<Bot>, bot: Bot,
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
) -> Self { ) -> Self {
Self { bot, chat_or_inline_message, reply_markup: None } Self { bot, chat_or_inline_message, reply_markup: None }

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, InlineKeyboardMarkup, Poll}, types::{ChatId, InlineKeyboardMarkup, Poll},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to stop a poll which was sent by the bot. /// Use this method to stop a poll which was sent by the bot.
/// ///
@ -15,7 +14,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct StopPoll { pub struct StopPoll {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
message_id: i32, message_id: i32,
reply_markup: Option<InlineKeyboardMarkup>, reply_markup: Option<InlineKeyboardMarkup>,
@ -39,7 +38,7 @@ impl Request for StopPoll {
} }
} }
impl StopPoll { impl StopPoll {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, message_id: i32) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, message_id: i32) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to unban a previously kicked user in a supergroup or /// Use this method to unban a previously kicked user in a supergroup or
/// channel. The user will **not** return to the group or channel automatically, /// channel. The user will **not** return to the group or channel automatically,
@ -18,7 +17,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct UnbanChatMember { pub struct UnbanChatMember {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
user_id: i32, user_id: i32,
} }
@ -39,7 +38,7 @@ impl Request for UnbanChatMember {
} }
impl UnbanChatMember { impl UnbanChatMember {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, user_id: i32) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C, user_id: i32) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to unpin a message in a group, a supergroup, or a channel. /// Use this method to unpin a message in a group, a supergroup, or a channel.
/// ///
@ -19,7 +18,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct UnpinChatMessage { pub struct UnpinChatMessage {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
chat_id: ChatId, chat_id: ChatId,
} }
@ -39,7 +38,7 @@ impl Request for UnpinChatMessage {
} }
impl UnpinChatMessage { impl UnpinChatMessage {
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self pub(crate) fn new<C>(bot: Bot, chat_id: C) -> Self
where where
C: Into<ChatId>, C: Into<ChatId>,
{ {

View file

@ -6,7 +6,6 @@ use crate::{
types::{File, InputFile}, types::{File, InputFile},
Bot, Bot,
}; };
use std::sync::Arc;
/// Use this method to upload a .png file with a sticker for later use in /// Use this method to upload a .png file with a sticker for later use in
/// [`Bot::create_new_sticker_set`] and [`Bot::add_sticker_to_set`] methods (can /// [`Bot::create_new_sticker_set`] and [`Bot::add_sticker_to_set`] methods (can
@ -20,7 +19,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct UploadStickerFile { pub struct UploadStickerFile {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: Arc<Bot>, bot: Bot,
user_id: i32, user_id: i32,
png_sticker: InputFile, png_sticker: InputFile,
} }
@ -40,11 +39,7 @@ impl Request for UploadStickerFile {
} }
impl UploadStickerFile { impl UploadStickerFile {
pub(crate) fn new( pub(crate) fn new(bot: Bot, user_id: i32, png_sticker: InputFile) -> Self {
bot: Arc<Bot>,
user_id: i32,
png_sticker: InputFile,
) -> Self {
Self { bot, user_id, png_sticker } Self { bot, user_id, png_sticker }
} }