mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Extract Bot from Arc
This commit is contained in:
parent
57d120b399
commit
23aa260d68
73 changed files with 334 additions and 512 deletions
|
@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### 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 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
|
||||
### 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)).
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
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 warp::Filter;
|
||||
|
||||
|
@ -22,7 +22,7 @@ async fn handle_rejection(
|
|||
}
|
||||
|
||||
pub async fn webhook<'a>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
) -> impl update_listeners::UpdateListener<Infallible> {
|
||||
// Heroku defines auto defines a port value
|
||||
let teloxide_token = env::var("TELOXIDE_TOKEN")
|
||||
|
@ -79,7 +79,7 @@ async fn run() {
|
|||
|
||||
let bot = Bot::from_env();
|
||||
|
||||
Dispatcher::new(Arc::clone(&bot))
|
||||
Dispatcher::new(bot.clone())
|
||||
.messages_handler(|rx: DispatcherHandlerRx<Message>| {
|
||||
rx.for_each(|message| async move {
|
||||
message.answer_str("pong").await.log_on_error().await;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
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 warp::Filter;
|
||||
|
||||
|
@ -22,7 +22,7 @@ async fn handle_rejection(
|
|||
}
|
||||
|
||||
pub async fn webhook<'a>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
) -> impl update_listeners::UpdateListener<Infallible> {
|
||||
// You might want to specify a self-signed certificate via .certificate
|
||||
// method on SetWebhook.
|
||||
|
@ -60,7 +60,7 @@ async fn run() {
|
|||
|
||||
let bot = Bot::from_env();
|
||||
|
||||
Dispatcher::new(Arc::clone(&bot))
|
||||
Dispatcher::new(bot.clone())
|
||||
.messages_handler(|rx: DispatcherHandlerRx<Message>| {
|
||||
rx.for_each(|message| async move {
|
||||
message.answer_str("pong").await.log_on_error().await;
|
||||
|
|
425
src/bot/api.rs
425
src/bot/api.rs
File diff suppressed because it is too large
Load diff
|
@ -6,11 +6,13 @@ mod api;
|
|||
mod download;
|
||||
|
||||
/// A Telegram bot used to send requests.
|
||||
///
|
||||
/// No need to put `Bot` into `Arc`, because it's already in.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Bot {
|
||||
token: String,
|
||||
token: Arc<str>,
|
||||
client: Client,
|
||||
parse_mode: Option<ParseMode>,
|
||||
parse_mode: Arc<Option<ParseMode>>,
|
||||
}
|
||||
|
||||
impl Bot {
|
||||
|
@ -22,7 +24,7 @@ impl Bot {
|
|||
///
|
||||
/// [`reqwest::Client`]: https://docs.rs/reqwest/0.10.1/reqwest/struct.Client.html
|
||||
#[allow(deprecated)]
|
||||
pub fn from_env() -> Arc<Self> {
|
||||
pub fn from_env() -> Self {
|
||||
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
|
||||
#[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(
|
||||
&std::env::var("TELOXIDE_TOKEN")
|
||||
.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
|
||||
#[deprecated]
|
||||
#[allow(deprecated)]
|
||||
pub fn new<S>(token: S) -> Arc<Self>
|
||||
pub fn new<S>(token: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
|
@ -62,11 +64,15 @@ impl Bot {
|
|||
/// [`reqwest::Client`]: https://docs.rs/reqwest/0.10.1/reqwest/struct.Client.html
|
||||
#[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
|
||||
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 {
|
||||
Bot {
|
||||
client: self.client.unwrap_or_default(),
|
||||
token: self.token.unwrap_or_else(|| {
|
||||
std::env::var("TELOXIDE_TOKEN")
|
||||
.expect("Cannot get the TELOXIDE_TOKEN env variable")
|
||||
}),
|
||||
parse_mode: self.parse_mode,
|
||||
token: self
|
||||
.token
|
||||
.unwrap_or_else(|| {
|
||||
std::env::var("TELOXIDE_TOKEN")
|
||||
.expect("Cannot get the TELOXIDE_TOKEN env variable")
|
||||
})
|
||||
.into(),
|
||||
parse_mode: Arc::new(self.parse_mode),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ mod macros {
|
|||
}
|
||||
|
||||
fn send<'a, Upd>(
|
||||
bot: &'a Arc<Bot>,
|
||||
bot: &'a Bot,
|
||||
tx: &'a Tx<Upd>,
|
||||
update: Upd,
|
||||
variant: &'static str,
|
||||
|
@ -35,9 +35,7 @@ fn send<'a, Upd>(
|
|||
Upd: Debug,
|
||||
{
|
||||
if let Some(tx) = tx {
|
||||
if let Err(error) =
|
||||
tx.send(UpdateWithCx { bot: Arc::clone(&bot), update })
|
||||
{
|
||||
if let Err(error) = tx.send(UpdateWithCx { bot: bot.clone(), update }) {
|
||||
log::error!(
|
||||
"The RX part of the {} channel is closed, but an update is \
|
||||
received.\nError:{}\n",
|
||||
|
@ -53,7 +51,7 @@ fn send<'a, Upd>(
|
|||
/// See [the module-level documentation for the design
|
||||
/// overview](crate::dispatching).
|
||||
pub struct Dispatcher {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
|
||||
messages_queue: Tx<Message>,
|
||||
edited_messages_queue: Tx<Message>,
|
||||
|
@ -71,7 +69,7 @@ pub struct Dispatcher {
|
|||
impl Dispatcher {
|
||||
/// Constructs a new dispatcher with the specified `bot`.
|
||||
#[must_use]
|
||||
pub fn new(bot: Arc<Bot>) -> Self {
|
||||
pub fn new(bot: Bot) -> Self {
|
||||
Self {
|
||||
bot,
|
||||
messages_queue: None,
|
||||
|
@ -207,7 +205,7 @@ impl Dispatcher {
|
|||
/// errors produced by this listener).
|
||||
pub async fn dispatch(&self) {
|
||||
self.dispatch_with_listener(
|
||||
update_listeners::polling_default(Arc::clone(&self.bot)),
|
||||
update_listeners::polling_default(self.bot.clone()),
|
||||
LoggingErrorHandler::with_custom_text(
|
||||
"An error from the update listener",
|
||||
),
|
||||
|
|
|
@ -112,7 +112,7 @@ use crate::{
|
|||
RequestError,
|
||||
};
|
||||
|
||||
use std::{convert::TryInto, sync::Arc, time::Duration};
|
||||
use std::{convert::TryInto, time::Duration};
|
||||
|
||||
/// A generic update listener.
|
||||
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.
|
||||
///
|
||||
/// 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)
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ pub fn polling_default(bot: Arc<Bot>) -> impl UpdateListener<RequestError> {
|
|||
///
|
||||
/// [`GetUpdates`]: crate::requests::GetUpdates
|
||||
pub fn polling(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
timeout: Option<Duration>,
|
||||
limit: Option<u8>,
|
||||
allowed_updates: Option<Vec<AllowedUpdate>>,
|
||||
|
|
|
@ -9,7 +9,6 @@ use crate::{
|
|||
types::{ChatId, ChatOrInlineMessage, InputFile, InputMedia, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A [`Dispatcher`]'s handler's context of a bot and an update.
|
||||
///
|
||||
|
@ -19,7 +18,7 @@ use std::sync::Arc;
|
|||
/// [`Dispatcher`]: crate::dispatching::Dispatcher
|
||||
#[derive(Debug)]
|
||||
pub struct UpdateWithCx<Upd> {
|
||||
pub bot: Arc<Bot>,
|
||||
pub bot: Bot,
|
||||
pub update: Upd,
|
||||
}
|
||||
|
||||
|
|
|
@ -6,14 +6,13 @@ use crate::{
|
|||
};
|
||||
|
||||
use crate::requests::{RequestWithFile, ResponseResult};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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).
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AddStickerToSet {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
user_id: i32,
|
||||
name: String,
|
||||
png_sticker: InputFile,
|
||||
|
@ -45,7 +44,7 @@ impl RequestWithFile for AddStickerToSet {
|
|||
|
||||
impl AddStickerToSet {
|
||||
pub(crate) fn new<N, E>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
user_id: i32,
|
||||
name: N,
|
||||
png_sticker: InputFile,
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::True,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send answers to callback queries sent from [inline
|
||||
/// keyboards].
|
||||
|
@ -21,7 +20,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct AnswerCallbackQuery {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
callback_query_id: String,
|
||||
text: Option<String>,
|
||||
show_alert: Option<bool>,
|
||||
|
@ -45,7 +44,7 @@ impl Request for 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
|
||||
C: Into<String>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{InlineQueryResult, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send answers to an inline query.
|
||||
///
|
||||
|
@ -17,7 +16,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct AnswerInlineQuery {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
inline_query_id: String,
|
||||
results: Vec<InlineQueryResult>,
|
||||
cache_time: Option<i32>,
|
||||
|
@ -43,11 +42,7 @@ impl Request for AnswerInlineQuery {
|
|||
}
|
||||
|
||||
impl AnswerInlineQuery {
|
||||
pub(crate) fn new<I, R>(
|
||||
bot: Arc<Bot>,
|
||||
inline_query_id: I,
|
||||
results: R,
|
||||
) -> Self
|
||||
pub(crate) fn new<I, R>(bot: Bot, inline_query_id: I, results: R) -> Self
|
||||
where
|
||||
I: Into<String>,
|
||||
R: Into<Vec<InlineQueryResult>>,
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::True,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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
|
||||
|
@ -21,7 +20,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct AnswerPreCheckoutQuery {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
pre_checkout_query_id: String,
|
||||
ok: bool,
|
||||
error_message: Option<String>,
|
||||
|
@ -43,11 +42,7 @@ impl Request for AnswerPreCheckoutQuery {
|
|||
}
|
||||
|
||||
impl AnswerPreCheckoutQuery {
|
||||
pub(crate) fn new<P>(
|
||||
bot: Arc<Bot>,
|
||||
pre_checkout_query_id: P,
|
||||
ok: bool,
|
||||
) -> Self
|
||||
pub(crate) fn new<P>(bot: Bot, pre_checkout_query_id: P, ok: bool) -> Self
|
||||
where
|
||||
P: Into<String>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ShippingOption, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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
|
||||
|
@ -20,7 +19,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct AnswerShippingQuery {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
shipping_query_id: String,
|
||||
ok: bool,
|
||||
shipping_options: Option<Vec<ShippingOption>>,
|
||||
|
@ -43,7 +42,7 @@ impl Request for 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
|
||||
S: Into<String>,
|
||||
{
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::{
|
|||
types::{InputFile, MaskPosition, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to create new sticker set owned by a user. The bot will be
|
||||
/// 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).
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CreateNewStickerSet {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
user_id: i32,
|
||||
name: String,
|
||||
title: String,
|
||||
|
@ -48,7 +47,7 @@ impl RequestWithFile for CreateNewStickerSet {
|
|||
|
||||
impl CreateNewStickerSet {
|
||||
pub(crate) fn new<N, T, E>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
user_id: i32,
|
||||
name: N,
|
||||
title: T,
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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
|
||||
|
@ -17,7 +16,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DeleteChatPhoto {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
|
@ -37,7 +36,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to delete a group sticker set from a supergroup.
|
||||
///
|
||||
|
@ -22,7 +21,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DeleteChatStickerSet {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
|
@ -42,7 +41,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to delete a message, including service messages.
|
||||
///
|
||||
|
@ -27,7 +26,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DeleteMessage {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
message_id: i32,
|
||||
}
|
||||
|
@ -48,7 +47,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::True,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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)]
|
||||
pub struct DeleteStickerFromSet {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
sticker: String,
|
||||
}
|
||||
|
||||
|
@ -35,7 +34,7 @@ impl Request for 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
|
||||
S: Into<String>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::True,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to remove webhook integration if you decide to switch back
|
||||
/// to [Bot::get_updates].
|
||||
|
@ -18,7 +17,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DeleteWebhook {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
@ -38,7 +37,7 @@ impl Request for DeleteWebhook {
|
|||
}
|
||||
|
||||
impl DeleteWebhook {
|
||||
pub(crate) fn new(bot: Arc<Bot>) -> Self {
|
||||
pub(crate) fn new(bot: Bot) -> Self {
|
||||
Self { bot }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to edit captions of messages.
|
||||
///
|
||||
|
@ -21,7 +20,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct EditMessageCaption {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
caption: Option<String>,
|
||||
|
@ -46,7 +45,7 @@ impl Request for EditMessageCaption {
|
|||
|
||||
impl EditMessageCaption {
|
||||
pub(crate) fn new(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to edit live location messages.
|
||||
///
|
||||
|
@ -23,7 +22,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct EditMessageLiveLocation {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
latitude: f32,
|
||||
|
@ -48,7 +47,7 @@ impl Request for EditMessageLiveLocation {
|
|||
|
||||
impl EditMessageLiveLocation {
|
||||
pub(crate) fn new(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
latitude: f32,
|
||||
longitude: f32,
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::{
|
|||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, InputMedia, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to edit animation, audio, document, photo, or video
|
||||
/// messages.
|
||||
|
@ -22,7 +21,7 @@ use std::sync::Arc;
|
|||
/// [`True`]: crate::types::True
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EditMessageMedia {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
media: InputMedia,
|
||||
reply_markup: Option<InlineKeyboardMarkup>,
|
||||
|
@ -62,7 +61,7 @@ impl Request for EditMessageMedia {
|
|||
|
||||
impl EditMessageMedia {
|
||||
pub(crate) fn new(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
media: InputMedia,
|
||||
) -> Self {
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to edit only the reply markup of messages.
|
||||
///
|
||||
|
@ -21,7 +20,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct EditMessageReplyMarkup {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
reply_markup: Option<InlineKeyboardMarkup>,
|
||||
|
@ -44,7 +43,7 @@ impl Request for EditMessageReplyMarkup {
|
|||
|
||||
impl EditMessageReplyMarkup {
|
||||
pub(crate) fn new(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
) -> Self {
|
||||
Self { bot, chat_or_inline_message, reply_markup: None }
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to edit text and game messages.
|
||||
///
|
||||
|
@ -21,7 +20,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct EditMessageText {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
text: String,
|
||||
|
@ -47,7 +46,7 @@ impl Request for EditMessageText {
|
|||
|
||||
impl EditMessageText {
|
||||
pub(crate) fn new<T>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
text: T,
|
||||
) -> Self
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::ChatId,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to generate a new invite link for a chat; any previously
|
||||
/// generated link is revoked.
|
||||
|
@ -31,7 +30,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct ExportChatInviteLink {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
|
@ -52,7 +51,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to forward messages of any kind.
|
||||
///
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct ForwardMessage {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
from_chat_id: ChatId,
|
||||
disable_notification: Option<bool>,
|
||||
|
@ -39,7 +38,7 @@ impl Request for ForwardMessage {
|
|||
|
||||
impl ForwardMessage {
|
||||
pub(crate) fn new<C, F>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: C,
|
||||
from_chat_id: F,
|
||||
message_id: i32,
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{Chat, ChatId},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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
|
||||
|
@ -17,7 +16,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetChat {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
|
@ -32,7 +31,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, ChatMember},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get a list of administrators in a chat.
|
||||
///
|
||||
|
@ -18,7 +17,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetChatAdministrators {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
|
@ -40,7 +39,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, ChatMember},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get information about a member of a chat.
|
||||
///
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetChatMember {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
}
|
||||
|
@ -36,7 +35,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::ChatId,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get the number of members in a chat.
|
||||
///
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetChatMembersCount {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
|
@ -35,7 +34,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::File,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get basic info about a file and prepare it for
|
||||
/// downloading.
|
||||
|
@ -31,7 +30,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetFile {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
file_id: String,
|
||||
}
|
||||
|
||||
|
@ -46,7 +45,7 @@ impl Request for 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
|
||||
F: Into<String>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatOrInlineMessage, GameHighScore},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get data for high score tables.
|
||||
///
|
||||
|
@ -24,7 +23,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetGameHighScores {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
user_id: i32,
|
||||
|
@ -47,7 +46,7 @@ impl Request for GetGameHighScores {
|
|||
|
||||
impl GetGameHighScores {
|
||||
pub(crate) fn new(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
user_id: i32,
|
||||
) -> Self {
|
||||
|
|
|
@ -5,7 +5,6 @@ use crate::{
|
|||
Bot,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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)]
|
||||
pub struct GetMe {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
@ -29,7 +28,7 @@ impl Request for GetMe {
|
|||
}
|
||||
|
||||
impl GetMe {
|
||||
pub(crate) fn new(bot: Arc<Bot>) -> Self {
|
||||
pub(crate) fn new(bot: Bot) -> Self {
|
||||
Self { bot }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::StickerSet,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get a sticker set.
|
||||
///
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetStickerSet {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -35,7 +34,7 @@ impl Request for 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
|
||||
N: Into<String>,
|
||||
{
|
||||
|
|
|
@ -7,7 +7,6 @@ use crate::{
|
|||
Bot, RequestError,
|
||||
};
|
||||
use serde_json::Value;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to receive incoming updates using long polling ([wiki]).
|
||||
///
|
||||
|
@ -23,7 +22,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetUpdates {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
pub(crate) offset: Option<i32>,
|
||||
pub(crate) limit: Option<u8>,
|
||||
pub(crate) timeout: Option<u32>,
|
||||
|
@ -64,7 +63,7 @@ impl Request for GetUpdates {
|
|||
}
|
||||
|
||||
impl GetUpdates {
|
||||
pub(crate) fn new(bot: Arc<Bot>) -> Self {
|
||||
pub(crate) fn new(bot: Bot) -> Self {
|
||||
Self {
|
||||
bot,
|
||||
offset: None,
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::UserProfilePhotos,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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)]
|
||||
pub struct GetUserProfilePhotos {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
user_id: i32,
|
||||
offset: Option<i32>,
|
||||
limit: Option<i32>,
|
||||
|
@ -37,7 +36,7 @@ impl Request for 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 }
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::WebhookInfo,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get current webhook status.
|
||||
///
|
||||
|
@ -19,7 +18,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetWebhookInfo {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
@ -39,7 +38,7 @@ impl Request for GetWebhookInfo {
|
|||
}
|
||||
|
||||
impl GetWebhookInfo {
|
||||
pub(crate) fn new(bot: Arc<Bot>) -> Self {
|
||||
pub(crate) fn new(bot: Bot) -> Self {
|
||||
Self { bot }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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)]
|
||||
pub struct KickChatMember {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
until_date: Option<i32>,
|
||||
|
@ -44,7 +43,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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)]
|
||||
pub struct LeaveChat {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
|
@ -35,7 +34,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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)]
|
||||
pub struct PinChatMessage {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
message_id: i32,
|
||||
disable_notification: Option<bool>,
|
||||
|
@ -41,7 +40,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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)]
|
||||
pub struct PromoteChatMember {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
can_change_info: Option<bool>,
|
||||
|
@ -48,7 +47,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, ChatPermissions, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to restrict a user in a supergroup.
|
||||
///
|
||||
|
@ -19,7 +18,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct RestrictChatMember {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
permissions: ChatPermissions,
|
||||
|
@ -43,7 +42,7 @@ impl Request for RestrictChatMember {
|
|||
|
||||
impl RestrictChatMember {
|
||||
pub(crate) fn new<C>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: C,
|
||||
user_id: i32,
|
||||
permissions: ChatPermissions,
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::{
|
|||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send animation files (GIF or H.264/MPEG-4 AVC video
|
||||
/// without sound).
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
/// [The official docs](https://core.telegram.org/bots/api#sendanimation).
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendAnimation {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
pub chat_id: ChatId,
|
||||
pub animation: InputFile,
|
||||
pub duration: Option<u32>,
|
||||
|
@ -60,11 +59,7 @@ impl RequestWithFile for SendAnimation {
|
|||
}
|
||||
|
||||
impl SendAnimation {
|
||||
pub(crate) fn new<C>(
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
animation: InputFile,
|
||||
) -> Self
|
||||
pub(crate) fn new<C>(bot: Bot, chat_id: C, animation: InputFile) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::{
|
|||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send audio files, if you want Telegram clients to display
|
||||
/// them in the music player.
|
||||
|
@ -19,7 +18,7 @@ use std::sync::Arc;
|
|||
/// [`Bot::send_voice`]: crate::Bot::send_voice
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendAudio {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
audio: InputFile,
|
||||
caption: Option<String>,
|
||||
|
@ -64,7 +63,7 @@ impl RequestWithFile for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method when you need to tell the user that something is happening
|
||||
/// on the bot's side.
|
||||
|
@ -29,7 +28,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendChatAction {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
action: SendChatActionKind,
|
||||
}
|
||||
|
@ -88,7 +87,7 @@ impl Request for SendChatAction {
|
|||
|
||||
impl SendChatAction {
|
||||
pub(crate) fn new<C>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: C,
|
||||
action: SendChatActionKind,
|
||||
) -> Self
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, Message, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send phone contacts.
|
||||
///
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendContact {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
phone_number: String,
|
||||
first_name: String,
|
||||
|
@ -43,7 +42,7 @@ impl Request for SendContact {
|
|||
|
||||
impl SendContact {
|
||||
pub(crate) fn new<C, P, F>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: C,
|
||||
phone_number: P,
|
||||
first_name: F,
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::{
|
|||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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).
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendDocument {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
document: InputFile,
|
||||
thumb: Option<InputFile>,
|
||||
|
@ -53,7 +52,7 @@ impl RequestWithFile for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send a game.
|
||||
///
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendGame {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: i32,
|
||||
game_short_name: String,
|
||||
disable_notification: Option<bool>,
|
||||
|
@ -39,11 +38,7 @@ impl Request for SendGame {
|
|||
}
|
||||
|
||||
impl SendGame {
|
||||
pub(crate) fn new<G>(
|
||||
bot: Arc<Bot>,
|
||||
chat_id: i32,
|
||||
game_short_name: G,
|
||||
) -> Self
|
||||
pub(crate) fn new<G>(bot: Bot, chat_id: i32, game_short_name: G) -> Self
|
||||
where
|
||||
G: Into<String>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{InlineKeyboardMarkup, LabeledPrice, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send invoices.
|
||||
///
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendInvoice {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: i32,
|
||||
title: String,
|
||||
description: String,
|
||||
|
@ -59,7 +58,7 @@ impl Request for SendInvoice {
|
|||
impl SendInvoice {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn new<T, D, Pl, Pt, S, C, Pr>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: i32,
|
||||
title: T,
|
||||
description: D,
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, Message, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send point on the map.
|
||||
///
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendLocation {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
latitude: f32,
|
||||
longitude: f32,
|
||||
|
@ -42,7 +41,7 @@ impl Request for SendLocation {
|
|||
|
||||
impl SendLocation {
|
||||
pub(crate) fn new<C>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: C,
|
||||
latitude: f32,
|
||||
longitude: f32,
|
||||
|
|
|
@ -4,14 +4,13 @@ use crate::{
|
|||
types::{ChatId, InputMedia, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send a group of photos or videos as an album.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendmediagroup).
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendMediaGroup {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
media: Vec<InputMedia>, // TODO: InputMediaPhoto and InputMediaVideo
|
||||
disable_notification: Option<bool>,
|
||||
|
@ -39,7 +38,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
M: Into<Vec<InputMedia>>,
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send text messages.
|
||||
///
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendMessage {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
pub chat_id: ChatId,
|
||||
pub text: String,
|
||||
pub parse_mode: Option<ParseMode>,
|
||||
|
@ -41,7 +40,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
T: Into<String>,
|
||||
|
|
|
@ -4,14 +4,13 @@ use crate::{
|
|||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send photos.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendphoto).
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendPhoto {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
photo: InputFile,
|
||||
caption: Option<String>,
|
||||
|
@ -46,7 +45,7 @@ impl RequestWithFile for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, Message, PollType, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send a native poll.
|
||||
///
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendPoll {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
question: String,
|
||||
options: Vec<String>,
|
||||
|
@ -46,7 +45,7 @@ impl Request for SendPoll {
|
|||
|
||||
impl SendPoll {
|
||||
pub(crate) fn new<C, Q, O>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: C,
|
||||
question: Q,
|
||||
options: O,
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::{
|
|||
types::{ChatId, InputFile, Message, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendSticker {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
sticker: InputFile,
|
||||
disable_notification: Option<bool>,
|
||||
|
@ -44,7 +43,7 @@ impl RequestWithFile for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, Message, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send information about a venue.
|
||||
///
|
||||
|
@ -15,7 +14,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendVenue {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
latitude: f32,
|
||||
longitude: f32,
|
||||
|
@ -45,7 +44,7 @@ impl Request for SendVenue {
|
|||
|
||||
impl SendVenue {
|
||||
pub(crate) fn new<C, T, A>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: C,
|
||||
latitude: f32,
|
||||
longitude: f32,
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::{
|
|||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send video files, Telegram clients support mp4 videos
|
||||
/// (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).
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendVideo {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
video: InputFile,
|
||||
duration: Option<i32>,
|
||||
|
@ -62,7 +61,7 @@ impl RequestWithFile for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::{
|
|||
types::{ChatId, InputFile, Message, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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.
|
||||
|
@ -14,7 +13,7 @@ use std::sync::Arc;
|
|||
/// [v.4.0]: https://telegram.org/blog/video-messages-and-telescope
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendVideoNote {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
video_note: InputFile,
|
||||
duration: Option<i32>,
|
||||
|
@ -53,11 +52,7 @@ impl RequestWithFile for SendVideoNote {
|
|||
}
|
||||
|
||||
impl SendVideoNote {
|
||||
pub(crate) fn new<C>(
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
video_note: InputFile,
|
||||
) -> Self
|
||||
pub(crate) fn new<C>(bot: Bot, chat_id: C, video_note: InputFile) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::{
|
|||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send audio files, if you want Telegram clients to display
|
||||
/// the file as a playable voice message.
|
||||
|
@ -20,7 +19,7 @@ use std::sync::Arc;
|
|||
/// [`Document`]: crate::types::Document
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendVoice {
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
voice: InputFile,
|
||||
caption: Option<String>,
|
||||
|
@ -57,7 +56,7 @@ impl RequestWithFile for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to set a custom title for an administrator in a supergroup
|
||||
/// promoted by the bot.
|
||||
|
@ -16,7 +15,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetChatAdministratorCustomTitle {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
custom_title: String,
|
||||
|
@ -39,7 +38,7 @@ impl Request for SetChatAdministratorCustomTitle {
|
|||
|
||||
impl SetChatAdministratorCustomTitle {
|
||||
pub(crate) fn new<C, CT>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: C,
|
||||
user_id: i32,
|
||||
custom_title: CT,
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to change the description of a group, a supergroup or a
|
||||
/// channel.
|
||||
|
@ -19,7 +18,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetChatDescription {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
description: Option<String>,
|
||||
}
|
||||
|
@ -40,7 +39,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, ChatPermissions, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to set default chat permissions for all members.
|
||||
///
|
||||
|
@ -18,7 +17,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetChatPermissions {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
permissions: ChatPermissions,
|
||||
}
|
||||
|
@ -40,7 +39,7 @@ impl Request for SetChatPermissions {
|
|||
|
||||
impl SetChatPermissions {
|
||||
pub(crate) fn new<C>(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: C,
|
||||
permissions: ChatPermissions,
|
||||
) -> Self
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, InputFile, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to set a new profile photo for the chat.
|
||||
///
|
||||
|
@ -18,7 +17,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetChatPhoto {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
photo: InputFile,
|
||||
}
|
||||
|
@ -39,7 +38,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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)]
|
||||
pub struct SetChatStickerSet {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
sticker_set_name: String,
|
||||
}
|
||||
|
@ -40,11 +39,7 @@ impl Request for SetChatStickerSet {
|
|||
}
|
||||
|
||||
impl SetChatStickerSet {
|
||||
pub(crate) fn new<C, S>(
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
sticker_set_name: S,
|
||||
) -> Self
|
||||
pub(crate) fn new<C, S>(bot: Bot, chat_id: C, sticker_set_name: S) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
S: Into<String>,
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to change the title of a chat.
|
||||
///
|
||||
|
@ -18,7 +17,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetChatTitle {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
title: String,
|
||||
}
|
||||
|
@ -39,7 +38,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
T: Into<String>,
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatOrInlineMessage, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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)]
|
||||
pub struct SetGameScore {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
user_id: i32,
|
||||
|
@ -49,7 +48,7 @@ impl Request for SetGameScore {
|
|||
|
||||
impl SetGameScore {
|
||||
pub(crate) fn new(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
user_id: i32,
|
||||
score: i32,
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::True,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to move a sticker in a set created by the bot to a specific
|
||||
/// position.
|
||||
|
@ -16,7 +15,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetStickerPositionInSet {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
sticker: String,
|
||||
position: i32,
|
||||
}
|
||||
|
@ -37,7 +36,7 @@ impl Request for 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
|
||||
S: Into<String>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{AllowedUpdate, InputFile, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to specify a url and receive incoming updates via an
|
||||
/// outgoing webhook.
|
||||
|
@ -28,7 +27,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetWebhook {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
url: String,
|
||||
certificate: Option<InputFile>,
|
||||
max_connections: Option<i32>,
|
||||
|
@ -51,7 +50,7 @@ impl Request for 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
|
||||
U: Into<String>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to stop updating a live location message before
|
||||
/// `live_period` expires.
|
||||
|
@ -22,7 +21,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct StopMessageLiveLocation {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
reply_markup: Option<InlineKeyboardMarkup>,
|
||||
|
@ -45,7 +44,7 @@ impl Request for StopMessageLiveLocation {
|
|||
|
||||
impl StopMessageLiveLocation {
|
||||
pub(crate) fn new(
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
) -> Self {
|
||||
Self { bot, chat_or_inline_message, reply_markup: None }
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, InlineKeyboardMarkup, Poll},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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)]
|
||||
pub struct StopPoll {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
message_id: i32,
|
||||
reply_markup: Option<InlineKeyboardMarkup>,
|
||||
|
@ -39,7 +38,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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,
|
||||
|
@ -18,7 +17,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct UnbanChatMember {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
}
|
||||
|
@ -39,7 +38,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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)]
|
||||
pub struct UnpinChatMessage {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
|
@ -39,7 +38,7 @@ impl Request for 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
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
types::{File, InputFile},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// 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
|
||||
|
@ -20,7 +19,7 @@ use std::sync::Arc;
|
|||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct UploadStickerFile {
|
||||
#[serde(skip_serializing)]
|
||||
bot: Arc<Bot>,
|
||||
bot: Bot,
|
||||
user_id: i32,
|
||||
png_sticker: InputFile,
|
||||
}
|
||||
|
@ -40,11 +39,7 @@ impl Request for UploadStickerFile {
|
|||
}
|
||||
|
||||
impl UploadStickerFile {
|
||||
pub(crate) fn new(
|
||||
bot: Arc<Bot>,
|
||||
user_id: i32,
|
||||
png_sticker: InputFile,
|
||||
) -> Self {
|
||||
pub(crate) fn new(bot: Bot, user_id: i32, png_sticker: InputFile) -> Self {
|
||||
Self { bot, user_id, png_sticker }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue