mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-18 15:20:15 +01:00
Use Arc<Bot> instead of BotWrapper
This commit is contained in:
parent
9525414f8d
commit
4a7c31fec7
68 changed files with 745 additions and 723 deletions
345
src/bot/api.rs
345
src/bot/api.rs
File diff suppressed because it is too large
Load diff
|
@ -5,15 +5,15 @@ use crate::{
|
|||
Bot,
|
||||
};
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::requests::{Request, 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(PartialEq, Debug, Clone)]
|
||||
pub struct AddStickerToSet<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AddStickerToSet {
|
||||
bot: Arc<Bot>,
|
||||
user_id: i32,
|
||||
name: String,
|
||||
png_sticker: InputFile,
|
||||
|
@ -22,7 +22,7 @@ pub struct AddStickerToSet<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for AddStickerToSet<'_> {
|
||||
impl Request for AddStickerToSet {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -47,9 +47,9 @@ impl Request for AddStickerToSet<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> AddStickerToSet<'a> {
|
||||
impl AddStickerToSet {
|
||||
pub(crate) fn new<N, E>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
user_id: i32,
|
||||
name: N,
|
||||
png_sticker: InputFile,
|
||||
|
@ -60,7 +60,7 @@ impl<'a> AddStickerToSet<'a> {
|
|||
E: Into<String>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
user_id,
|
||||
name: name.into(),
|
||||
png_sticker,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::True,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send answers to callback queries sent from [inline
|
||||
/// keyboards].
|
||||
|
@ -18,10 +18,10 @@ use crate::{
|
|||
///
|
||||
/// [inline keyboards]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct AnswerCallbackQuery<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct AnswerCallbackQuery {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
callback_query_id: String,
|
||||
text: Option<String>,
|
||||
show_alert: Option<bool>,
|
||||
|
@ -30,7 +30,7 @@ pub struct AnswerCallbackQuery<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for AnswerCallbackQuery<'_> {
|
||||
impl Request for AnswerCallbackQuery {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -44,14 +44,14 @@ impl Request for AnswerCallbackQuery<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> AnswerCallbackQuery<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, callback_query_id: C) -> Self
|
||||
impl AnswerCallbackQuery {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, callback_query_id: C) -> Self
|
||||
where
|
||||
C: Into<String>,
|
||||
{
|
||||
let callback_query_id = callback_query_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
callback_query_id,
|
||||
text: None,
|
||||
show_alert: None,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{InlineQueryResult, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send answers to an inline query.
|
||||
///
|
||||
|
@ -14,10 +14,10 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#answerinlinequery).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct AnswerInlineQuery<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct AnswerInlineQuery {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
inline_query_id: String,
|
||||
results: Vec<InlineQueryResult>,
|
||||
cache_time: Option<i32>,
|
||||
|
@ -28,7 +28,7 @@ pub struct AnswerInlineQuery<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for AnswerInlineQuery<'_> {
|
||||
impl Request for AnswerInlineQuery {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -42,9 +42,9 @@ impl Request for AnswerInlineQuery<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> AnswerInlineQuery<'a> {
|
||||
impl AnswerInlineQuery {
|
||||
pub(crate) fn new<I, R>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
inline_query_id: I,
|
||||
results: R,
|
||||
) -> Self
|
||||
|
@ -55,7 +55,7 @@ impl<'a> AnswerInlineQuery<'a> {
|
|||
let inline_query_id = inline_query_id.into();
|
||||
let results = results.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
inline_query_id,
|
||||
results,
|
||||
cache_time: None,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
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
|
||||
|
@ -18,17 +18,17 @@ use crate::{
|
|||
///
|
||||
/// [`Update`]: crate::types::Update
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct AnswerPreCheckoutQuery<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct AnswerPreCheckoutQuery {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
pre_checkout_query_id: String,
|
||||
ok: bool,
|
||||
error_message: Option<String>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for AnswerPreCheckoutQuery<'_> {
|
||||
impl Request for AnswerPreCheckoutQuery {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -42,9 +42,9 @@ impl Request for AnswerPreCheckoutQuery<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> AnswerPreCheckoutQuery<'a> {
|
||||
impl AnswerPreCheckoutQuery {
|
||||
pub(crate) fn new<P>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
pre_checkout_query_id: P,
|
||||
ok: bool,
|
||||
) -> Self
|
||||
|
@ -53,7 +53,7 @@ impl<'a> AnswerPreCheckoutQuery<'a> {
|
|||
{
|
||||
let pre_checkout_query_id = pre_checkout_query_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
pre_checkout_query_id,
|
||||
ok,
|
||||
error_message: None,
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
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
|
||||
/// shipping_query field to the bot. Use this method to reply to shipping
|
||||
|
@ -16,10 +17,10 @@ use crate::{
|
|||
///
|
||||
/// [`Update`]: crate::types::Update
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct AnswerShippingQuery<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct AnswerShippingQuery {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
shipping_query_id: String,
|
||||
ok: bool,
|
||||
shipping_options: Option<Vec<ShippingOption>>,
|
||||
|
@ -27,7 +28,7 @@ pub struct AnswerShippingQuery<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for AnswerShippingQuery<'_> {
|
||||
impl Request for AnswerShippingQuery {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -41,14 +42,14 @@ impl Request for AnswerShippingQuery<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> AnswerShippingQuery<'a> {
|
||||
pub(crate) fn new<S>(bot: &'a Bot, shipping_query_id: S, ok: bool) -> Self
|
||||
impl AnswerShippingQuery {
|
||||
pub(crate) fn new<S>(bot: Arc<Bot>, shipping_query_id: S, ok: bool) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
let shipping_query_id = shipping_query_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
shipping_query_id,
|
||||
ok,
|
||||
shipping_options: None,
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
use crate::Bot;
|
||||
use std::ops::Deref;
|
||||
|
||||
/// A wrapper that implements `Clone`, Copy, `PartialEq`, `Eq`, `Debug`, but
|
||||
/// performs no copying, cloning and comparison.
|
||||
///
|
||||
/// Used in the requests bodies.
|
||||
#[derive(Debug)]
|
||||
pub struct BotWrapper<'a>(pub &'a Bot);
|
||||
|
||||
impl PartialEq for BotWrapper<'_> {
|
||||
fn eq(&self, other: &BotWrapper<'_>) -> bool {
|
||||
self.0.token() == other.0.token()
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for BotWrapper<'_> {}
|
||||
|
||||
impl<'a> Clone for BotWrapper<'a> {
|
||||
fn clone(&self) -> BotWrapper<'a> {
|
||||
Self(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Copy for BotWrapper<'_> {}
|
||||
|
||||
impl Deref for BotWrapper<'_> {
|
||||
type Target = Bot;
|
||||
|
||||
fn deref(&self) -> &Bot {
|
||||
&self.0
|
||||
}
|
||||
}
|
|
@ -1,18 +1,18 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
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.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#createnewstickerset).
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
pub struct CreateNewStickerSet<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CreateNewStickerSet {
|
||||
bot: Arc<Bot>,
|
||||
user_id: i32,
|
||||
name: String,
|
||||
title: String,
|
||||
|
@ -23,7 +23,7 @@ pub struct CreateNewStickerSet<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for CreateNewStickerSet<'_> {
|
||||
impl Request for CreateNewStickerSet {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -52,9 +52,9 @@ impl Request for CreateNewStickerSet<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> CreateNewStickerSet<'a> {
|
||||
impl CreateNewStickerSet {
|
||||
pub(crate) fn new<N, T, E>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
user_id: i32,
|
||||
name: N,
|
||||
title: T,
|
||||
|
@ -67,7 +67,7 @@ impl<'a> CreateNewStickerSet<'a> {
|
|||
E: Into<String>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
user_id,
|
||||
name: name.into(),
|
||||
title: title.into(),
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
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
|
||||
|
@ -14,15 +14,15 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#deletechatphoto).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct DeleteChatPhoto<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DeleteChatPhoto {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for DeleteChatPhoto<'_> {
|
||||
impl Request for DeleteChatPhoto {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -36,16 +36,13 @@ impl Request for DeleteChatPhoto<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> DeleteChatPhoto<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self
|
||||
impl DeleteChatPhoto {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
chat_id,
|
||||
}
|
||||
Self { bot, chat_id }
|
||||
}
|
||||
|
||||
/// Unique identifier for the target chat or username of the target channel
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to delete a group sticker set from a supergroup.
|
||||
///
|
||||
|
@ -19,15 +19,15 @@ use crate::{
|
|||
///
|
||||
/// [`Bot::get_chat`]: crate::Bot::get_chat
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct DeleteChatStickerSet<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DeleteChatStickerSet {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for DeleteChatStickerSet<'_> {
|
||||
impl Request for DeleteChatStickerSet {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -41,16 +41,13 @@ impl Request for DeleteChatStickerSet<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> DeleteChatStickerSet<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self
|
||||
impl DeleteChatStickerSet {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
chat_id,
|
||||
}
|
||||
Self { bot, chat_id }
|
||||
}
|
||||
|
||||
/// Unique identifier for the target chat or username of the target
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to delete a message, including service messages.
|
||||
///
|
||||
|
@ -24,16 +24,16 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#deletemessage).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct DeleteMessage<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DeleteMessage {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
message_id: i32,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for DeleteMessage<'_> {
|
||||
impl Request for DeleteMessage {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -47,14 +47,14 @@ impl Request for DeleteMessage<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> DeleteMessage<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, message_id: i32) -> Self
|
||||
impl DeleteMessage {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, message_id: i32) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
message_id,
|
||||
}
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::True,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to delete a sticker from a set created by the bot.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#deletestickerfromset).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct DeleteStickerFromSet<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DeleteStickerFromSet {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
sticker: String,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for DeleteStickerFromSet<'_> {
|
||||
impl Request for DeleteStickerFromSet {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -34,16 +34,13 @@ impl Request for DeleteStickerFromSet<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> DeleteStickerFromSet<'a> {
|
||||
pub(crate) fn new<S>(bot: &'a Bot, sticker: S) -> Self
|
||||
impl DeleteStickerFromSet {
|
||||
pub(crate) fn new<S>(bot: Arc<Bot>, sticker: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
let sticker = sticker.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
sticker,
|
||||
}
|
||||
Self { bot, sticker }
|
||||
}
|
||||
|
||||
/// File identifier of the sticker.
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::True,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to remove webhook integration if you decide to switch back
|
||||
/// to [Bot::get_updates].
|
||||
|
@ -15,14 +15,14 @@ use crate::{
|
|||
///
|
||||
/// [Bot::get_updates]: crate::Bot::get_updates
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Copy, Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct DeleteWebhook<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DeleteWebhook {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for DeleteWebhook<'_> {
|
||||
impl Request for DeleteWebhook {
|
||||
type Output = True;
|
||||
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
|
@ -37,10 +37,8 @@ impl Request for DeleteWebhook<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> DeleteWebhook<'a> {
|
||||
pub(crate) fn new(bot: &'a Bot) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
}
|
||||
impl DeleteWebhook {
|
||||
pub(crate) fn new(bot: Arc<Bot>) -> Self {
|
||||
Self { bot }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to edit captions of messages.
|
||||
///
|
||||
|
@ -18,10 +18,10 @@ use crate::{
|
|||
/// [`Message`]: crate::types::Message
|
||||
/// [`True`]: crate::types::True
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct EditMessageCaption<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct EditMessageCaption {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
caption: Option<String>,
|
||||
|
@ -30,7 +30,7 @@ pub struct EditMessageCaption<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for EditMessageCaption<'_> {
|
||||
impl Request for EditMessageCaption {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -44,13 +44,13 @@ impl Request for EditMessageCaption<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> EditMessageCaption<'a> {
|
||||
impl EditMessageCaption {
|
||||
pub(crate) fn new(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_or_inline_message,
|
||||
caption: None,
|
||||
parse_mode: None,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to edit live location messages.
|
||||
///
|
||||
|
@ -20,10 +20,10 @@ use crate::{
|
|||
/// [`Message`]: crate::types::Message
|
||||
/// [`True`]: crate::types::True
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct EditMessageLiveLocation<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct EditMessageLiveLocation {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
latitude: f32,
|
||||
|
@ -32,7 +32,7 @@ pub struct EditMessageLiveLocation<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for EditMessageLiveLocation<'_> {
|
||||
impl Request for EditMessageLiveLocation {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -46,15 +46,15 @@ impl Request for EditMessageLiveLocation<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> EditMessageLiveLocation<'a> {
|
||||
impl EditMessageLiveLocation {
|
||||
pub(crate) fn new(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
latitude: f32,
|
||||
longitude: f32,
|
||||
) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_or_inline_message,
|
||||
latitude,
|
||||
longitude,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, InputMedia, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to edit animation, audio, document, photo, or video
|
||||
/// messages.
|
||||
|
@ -20,16 +20,16 @@ use crate::{
|
|||
///
|
||||
/// [`Message`]: crate::types::Message
|
||||
/// [`True`]: crate::types::True
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct EditMessageMedia<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EditMessageMedia {
|
||||
bot: Arc<Bot>,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
media: InputMedia,
|
||||
reply_markup: Option<InlineKeyboardMarkup>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for EditMessageMedia<'_> {
|
||||
impl Request for EditMessageMedia {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -67,14 +67,14 @@ impl Request for EditMessageMedia<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> EditMessageMedia<'a> {
|
||||
impl EditMessageMedia {
|
||||
pub(crate) fn new(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
media: InputMedia,
|
||||
) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_or_inline_message,
|
||||
media,
|
||||
reply_markup: None,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to edit only the reply markup of messages.
|
||||
///
|
||||
|
@ -18,17 +18,17 @@ use crate::{
|
|||
/// [`Message`]: crate::types::Message
|
||||
/// [`True`]: crate::types::True
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct EditMessageReplyMarkup<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct EditMessageReplyMarkup {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
reply_markup: Option<InlineKeyboardMarkup>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for EditMessageReplyMarkup<'_> {
|
||||
impl Request for EditMessageReplyMarkup {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -42,13 +42,13 @@ impl Request for EditMessageReplyMarkup<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> EditMessageReplyMarkup<'a> {
|
||||
impl EditMessageReplyMarkup {
|
||||
pub(crate) fn new(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_or_inline_message,
|
||||
reply_markup: None,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to edit text and game messages.
|
||||
///
|
||||
|
@ -18,10 +18,10 @@ use crate::{
|
|||
/// [`Message`]: crate::types::Message
|
||||
/// [`True`]: crate::types::True
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct EditMessageText<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct EditMessageText {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
text: String,
|
||||
|
@ -31,7 +31,7 @@ pub struct EditMessageText<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for EditMessageText<'_> {
|
||||
impl Request for EditMessageText {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -45,9 +45,9 @@ impl Request for EditMessageText<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> EditMessageText<'a> {
|
||||
impl EditMessageText {
|
||||
pub(crate) fn new<T>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
text: T,
|
||||
) -> Self
|
||||
|
@ -55,7 +55,7 @@ impl<'a> EditMessageText<'a> {
|
|||
T: Into<String>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_or_inline_message,
|
||||
text: text.into(),
|
||||
parse_mode: None,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
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.
|
||||
|
@ -28,15 +28,15 @@ use crate::{
|
|||
/// [`Bot::export_chat_invite_link`]: crate::Bot::export_chat_invite_link
|
||||
/// [`Bot::get_chat`]: crate::Bot::get_chat
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct ExportChatInviteLink<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct ExportChatInviteLink {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for ExportChatInviteLink<'_> {
|
||||
impl Request for ExportChatInviteLink {
|
||||
type Output = String;
|
||||
|
||||
/// Returns the new invite link as `String` on success.
|
||||
|
@ -51,16 +51,13 @@ impl Request for ExportChatInviteLink<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> ExportChatInviteLink<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self
|
||||
impl ExportChatInviteLink {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
chat_id,
|
||||
}
|
||||
Self { bot, chat_id }
|
||||
}
|
||||
|
||||
/// Unique identifier for the target chat or username of the target channel
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to forward messages of any kind.
|
||||
///
|
||||
/// [`The official docs`](https://core.telegram.org/bots/api#forwardmessage).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct ForwardMessage<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct ForwardMessage {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
from_chat_id: ChatId,
|
||||
disable_notification: Option<bool>,
|
||||
|
@ -23,7 +23,7 @@ pub struct ForwardMessage<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for ForwardMessage<'_> {
|
||||
impl Request for ForwardMessage {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -37,9 +37,9 @@ impl Request for ForwardMessage<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> ForwardMessage<'a> {
|
||||
impl ForwardMessage {
|
||||
pub(crate) fn new<C, F>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
from_chat_id: F,
|
||||
message_id: i32,
|
||||
|
@ -51,7 +51,7 @@ impl<'a> ForwardMessage<'a> {
|
|||
let chat_id = chat_id.into();
|
||||
let from_chat_id = from_chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
from_chat_id,
|
||||
message_id,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
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
|
||||
|
@ -14,15 +14,15 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#getchat).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct GetChat<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetChat {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetChat<'_> {
|
||||
impl Request for GetChat {
|
||||
type Output = Chat;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Chat> {
|
||||
|
@ -31,16 +31,13 @@ impl Request for GetChat<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetChat<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self
|
||||
impl GetChat {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
chat_id,
|
||||
}
|
||||
Self { bot, chat_id }
|
||||
}
|
||||
|
||||
/// Unique identifier for the target chat or username of the target
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, ChatMember},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get a list of administrators in a chat.
|
||||
///
|
||||
|
@ -15,15 +15,15 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#getchatadministrators).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct GetChatAdministrators<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetChatAdministrators {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetChatAdministrators<'_> {
|
||||
impl Request for GetChatAdministrators {
|
||||
type Output = Vec<ChatMember>;
|
||||
|
||||
/// On success, returns an array that contains information about all chat
|
||||
|
@ -39,16 +39,13 @@ impl Request for GetChatAdministrators<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetChatAdministrators<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self
|
||||
impl GetChatAdministrators {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
chat_id,
|
||||
}
|
||||
Self { bot, chat_id }
|
||||
}
|
||||
|
||||
/// Unique identifier for the target chat or username of the target
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, ChatMember},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get information about a member of a chat.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#getchatmember).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct GetChatMember<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetChatMember {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetChatMember<'_> {
|
||||
impl Request for GetChatMember {
|
||||
type Output = ChatMember;
|
||||
|
||||
async fn send(&self) -> ResponseResult<ChatMember> {
|
||||
|
@ -35,14 +35,14 @@ impl Request for GetChatMember<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetChatMember<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, user_id: i32) -> Self
|
||||
impl GetChatMember {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, user_id: i32) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
user_id,
|
||||
}
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::ChatId,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get the number of members in a chat.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#getchatmemberscount).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct GetChatMembersCount<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetChatMembersCount {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetChatMembersCount<'_> {
|
||||
impl Request for GetChatMembersCount {
|
||||
type Output = i32;
|
||||
|
||||
async fn send(&self) -> ResponseResult<i32> {
|
||||
|
@ -34,16 +34,13 @@ impl Request for GetChatMembersCount<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetChatMembersCount<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self
|
||||
impl GetChatMembersCount {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
chat_id,
|
||||
}
|
||||
Self { bot, chat_id }
|
||||
}
|
||||
|
||||
/// Unique identifier for the target chat or username of the target
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::File,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get basic info about a file and prepare it for
|
||||
/// downloading.
|
||||
|
@ -28,15 +28,15 @@ use crate::{
|
|||
/// [`File`]: crate::types::file
|
||||
/// [`GetFile`]: self::GetFile
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct GetFile<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetFile {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
file_id: String,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetFile<'_> {
|
||||
impl Request for GetFile {
|
||||
type Output = File;
|
||||
|
||||
async fn send(&self) -> ResponseResult<File> {
|
||||
|
@ -45,13 +45,13 @@ impl Request for GetFile<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetFile<'a> {
|
||||
pub(crate) fn new<F>(bot: &'a Bot, file_id: F) -> Self
|
||||
impl GetFile {
|
||||
pub(crate) fn new<F>(bot: Arc<Bot>, file_id: F) -> Self
|
||||
where
|
||||
F: Into<String>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
file_id: file_id.into(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, GameHighScore},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get data for high score tables.
|
||||
///
|
||||
|
@ -21,17 +21,17 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#getgamehighscores).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct GetGameHighScores<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetGameHighScores {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
user_id: i32,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetGameHighScores<'_> {
|
||||
impl Request for GetGameHighScores {
|
||||
type Output = Vec<GameHighScore>;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Vec<GameHighScore>> {
|
||||
|
@ -45,14 +45,14 @@ impl Request for GetGameHighScores<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetGameHighScores<'a> {
|
||||
impl GetGameHighScores {
|
||||
pub(crate) fn new(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
user_id: i32,
|
||||
) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_or_inline_message,
|
||||
user_id,
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
|
@ -6,18 +5,19 @@ use crate::{
|
|||
Bot,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A simple method for testing your bot's auth token. Requires no parameters.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#getme).
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Copy, Serialize)]
|
||||
pub struct GetMe<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetMe {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetMe<'_> {
|
||||
impl Request for GetMe {
|
||||
type Output = Me;
|
||||
|
||||
/// Returns basic information about the bot.
|
||||
|
@ -28,10 +28,8 @@ impl Request for GetMe<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetMe<'a> {
|
||||
pub(crate) fn new(bot: &'a Bot) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
}
|
||||
impl GetMe {
|
||||
pub(crate) fn new(bot: Arc<Bot>) -> Self {
|
||||
Self { bot }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::StickerSet,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get a sticker set.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#getstickerset).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct GetStickerSet<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetStickerSet {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetStickerSet<'_> {
|
||||
impl Request for GetStickerSet {
|
||||
type Output = StickerSet;
|
||||
|
||||
async fn send(&self) -> ResponseResult<StickerSet> {
|
||||
|
@ -34,16 +34,13 @@ impl Request for GetStickerSet<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetStickerSet<'a> {
|
||||
pub(crate) fn new<N>(bot: &'a Bot, name: N) -> Self
|
||||
impl GetStickerSet {
|
||||
pub(crate) fn new<N>(bot: Arc<Bot>, name: N) -> Self
|
||||
where
|
||||
N: Into<String>,
|
||||
{
|
||||
let name = name.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
name,
|
||||
}
|
||||
Self { bot, name }
|
||||
}
|
||||
|
||||
/// Name of the sticker set.
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{AllowedUpdate, Update},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to receive incoming updates using long polling ([wiki]).
|
||||
///
|
||||
|
@ -19,10 +19,10 @@ use crate::{
|
|||
///
|
||||
/// [wiki]: https://en.wikipedia.org/wiki/Push_technology#Long_polling
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct GetUpdates<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetUpdates {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
pub(crate) offset: Option<i32>,
|
||||
pub(crate) limit: Option<u8>,
|
||||
pub(crate) timeout: Option<u32>,
|
||||
|
@ -30,7 +30,7 @@ pub struct GetUpdates<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetUpdates<'_> {
|
||||
impl Request for GetUpdates {
|
||||
type Output = Vec<Update>;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Vec<Update>> {
|
||||
|
@ -44,10 +44,10 @@ impl Request for GetUpdates<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetUpdates<'a> {
|
||||
pub(crate) fn new(bot: &'a Bot) -> Self {
|
||||
impl GetUpdates {
|
||||
pub(crate) fn new(bot: Arc<Bot>) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
offset: None,
|
||||
limit: None,
|
||||
timeout: None,
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::UserProfilePhotos,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get a list of profile pictures for a user.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#getuserprofilephotos).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Copy, Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct GetUserProfilePhotos<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetUserProfilePhotos {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
user_id: i32,
|
||||
offset: Option<i32>,
|
||||
limit: Option<i32>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetUserProfilePhotos<'_> {
|
||||
impl Request for GetUserProfilePhotos {
|
||||
type Output = UserProfilePhotos;
|
||||
|
||||
async fn send(&self) -> ResponseResult<UserProfilePhotos> {
|
||||
|
@ -36,10 +36,10 @@ impl Request for GetUserProfilePhotos<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetUserProfilePhotos<'a> {
|
||||
pub(crate) fn new(bot: &'a Bot, user_id: i32) -> Self {
|
||||
impl GetUserProfilePhotos {
|
||||
pub(crate) fn new(bot: Arc<Bot>, user_id: i32) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
user_id,
|
||||
offset: None,
|
||||
limit: None,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::WebhookInfo,
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to get current webhook status.
|
||||
///
|
||||
|
@ -16,14 +16,14 @@ use crate::{
|
|||
/// [The official docs](https://core.telegram.org/bots/api#getwebhookinfo).
|
||||
///
|
||||
/// [`Bot::get_updates`]: crate::Bot::get_updates
|
||||
#[derive(Copy, Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct GetWebhookInfo<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetWebhookInfo {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetWebhookInfo<'_> {
|
||||
impl Request for GetWebhookInfo {
|
||||
type Output = WebhookInfo;
|
||||
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
|
@ -38,10 +38,8 @@ impl Request for GetWebhookInfo<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetWebhookInfo<'a> {
|
||||
pub(crate) fn new(bot: &'a Bot) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
}
|
||||
impl GetWebhookInfo {
|
||||
pub(crate) fn new(bot: Arc<Bot>) -> Self {
|
||||
Self { bot }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to kick a user from a group, a supergroup or a channel.
|
||||
///
|
||||
|
@ -19,17 +19,17 @@ use crate::{
|
|||
///
|
||||
/// [unbanned]: crate::Bot::unban_chat_member
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct KickChatMember<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct KickChatMember {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
until_date: Option<i32>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for KickChatMember<'_> {
|
||||
impl Request for KickChatMember {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -43,14 +43,14 @@ impl Request for KickChatMember<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> KickChatMember<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, user_id: i32) -> Self
|
||||
impl KickChatMember {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, user_id: i32) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
user_id,
|
||||
until_date: None,
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method for your bot to leave a group, supergroup or channel.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#leavechat).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct LeaveChat<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct LeaveChat {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for LeaveChat<'_> {
|
||||
impl Request for LeaveChat {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -34,16 +34,13 @@ impl Request for LeaveChat<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> LeaveChat<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self
|
||||
impl LeaveChat {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
chat_id,
|
||||
}
|
||||
Self { bot, chat_id }
|
||||
}
|
||||
|
||||
/// Unique identifier for the target chat or username of the target
|
||||
|
|
|
@ -130,6 +130,3 @@ pub use stop_poll::*;
|
|||
pub use unban_chat_member::*;
|
||||
pub use unpin_chat_message::*;
|
||||
pub use upload_sticker_file::*;
|
||||
|
||||
mod bot_wrapper;
|
||||
use bot_wrapper::BotWrapper;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to pin a message in a group, a supergroup, or a channel.
|
||||
///
|
||||
|
@ -16,17 +16,17 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#pinchatmessage).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct PinChatMessage<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct PinChatMessage {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
message_id: i32,
|
||||
disable_notification: Option<bool>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for PinChatMessage<'_> {
|
||||
impl Request for PinChatMessage {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -40,14 +40,14 @@ impl Request for PinChatMessage<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> PinChatMessage<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, message_id: i32) -> Self
|
||||
impl PinChatMessage {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, message_id: i32) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
message_id,
|
||||
disable_notification: None,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to promote or demote a user in a supergroup or a channel.
|
||||
///
|
||||
|
@ -16,10 +16,10 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#promotechatmember).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct PromoteChatMember<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct PromoteChatMember {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
can_change_info: Option<bool>,
|
||||
|
@ -33,7 +33,7 @@ pub struct PromoteChatMember<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for PromoteChatMember<'_> {
|
||||
impl Request for PromoteChatMember {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -47,14 +47,14 @@ impl Request for PromoteChatMember<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> PromoteChatMember<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, user_id: i32) -> Self
|
||||
impl PromoteChatMember {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, user_id: i32) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
user_id,
|
||||
can_change_info: None,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, ChatPermissions, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to restrict a user in a supergroup.
|
||||
///
|
||||
|
@ -16,10 +16,10 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#restrictchatmember).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct RestrictChatMember<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct RestrictChatMember {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
permissions: ChatPermissions,
|
||||
|
@ -27,7 +27,7 @@ pub struct RestrictChatMember<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for RestrictChatMember<'_> {
|
||||
impl Request for RestrictChatMember {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -41,9 +41,9 @@ impl Request for RestrictChatMember<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> RestrictChatMember<'a> {
|
||||
impl RestrictChatMember {
|
||||
pub(crate) fn new<C>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
user_id: i32,
|
||||
permissions: ChatPermissions,
|
||||
|
@ -53,7 +53,7 @@ impl<'a> RestrictChatMember<'a> {
|
|||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
user_id,
|
||||
permissions,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
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).
|
||||
|
@ -13,9 +13,9 @@ use crate::{
|
|||
/// may be changed in the future.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendanimation).
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct SendAnimation<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendAnimation {
|
||||
bot: Arc<Bot>,
|
||||
pub chat_id: ChatId,
|
||||
pub animation: InputFile,
|
||||
pub duration: Option<u32>,
|
||||
|
@ -30,7 +30,7 @@ pub struct SendAnimation<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendAnimation<'_> {
|
||||
impl Request for SendAnimation {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -67,13 +67,17 @@ impl Request for SendAnimation<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendAnimation<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, animation: InputFile) -> Self
|
||||
impl SendAnimation {
|
||||
pub(crate) fn new<C>(
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
animation: InputFile,
|
||||
) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
animation,
|
||||
duration: None,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
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.
|
||||
|
@ -17,9 +17,9 @@ use crate::{
|
|||
/// [The official docs](https://core.telegram.org/bots/api#sendaudio).
|
||||
///
|
||||
/// [`Bot::send_voice`]: crate::Bot::send_voice
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct SendAudio<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendAudio {
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
audio: InputFile,
|
||||
caption: Option<String>,
|
||||
|
@ -34,7 +34,7 @@ pub struct SendAudio<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendAudio<'_> {
|
||||
impl Request for SendAudio {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -71,13 +71,13 @@ impl Request for SendAudio<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendAudio<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, audio: InputFile) -> Self
|
||||
impl SendAudio {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, audio: InputFile) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
audio,
|
||||
caption: None,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
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.
|
||||
|
@ -26,10 +26,10 @@ use crate::{
|
|||
/// [ImageBot]: https://t.me/imagebot
|
||||
/// [`Bot::send_chat_action`]: crate::Bot::send_chat_action
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SendChatAction<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendChatAction {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
action: SendChatActionKind,
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ pub struct SendChatAction<'a> {
|
|||
/// A type of action used in [`SendChatAction`].
|
||||
///
|
||||
/// [`SendChatAction`]: crate::requests::SendChatAction
|
||||
#[derive(PartialEq, Copy, Clone, Debug, Eq, Hash, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum SendChatActionKind {
|
||||
/// For [text messages](crate::Bot::send_message).
|
||||
|
@ -72,7 +72,7 @@ pub enum SendChatActionKind {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendChatAction<'_> {
|
||||
impl Request for SendChatAction {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -86,9 +86,9 @@ impl Request for SendChatAction<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendChatAction<'a> {
|
||||
impl SendChatAction {
|
||||
pub(crate) fn new<C>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
action: SendChatActionKind,
|
||||
) -> Self
|
||||
|
@ -96,7 +96,7 @@ impl<'a> SendChatAction<'a> {
|
|||
C: Into<ChatId>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
action,
|
||||
}
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send phone contacts.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendcontact).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SendContact<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendContact {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
phone_number: String,
|
||||
first_name: String,
|
||||
|
@ -27,7 +27,7 @@ pub struct SendContact<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendContact<'_> {
|
||||
impl Request for SendContact {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -41,9 +41,9 @@ impl Request for SendContact<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendContact<'a> {
|
||||
impl SendContact {
|
||||
pub(crate) fn new<C, P, F>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
phone_number: P,
|
||||
first_name: F,
|
||||
|
@ -57,7 +57,7 @@ impl<'a> SendContact<'a> {
|
|||
let phone_number = phone_number.into();
|
||||
let first_name = first_name.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
phone_number,
|
||||
first_name,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send general files.
|
||||
///
|
||||
|
@ -12,9 +12,9 @@ use crate::{
|
|||
/// may be changed in the future.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#senddocument).
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct SendDocument<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendDocument {
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
document: InputFile,
|
||||
thumb: Option<InputFile>,
|
||||
|
@ -26,7 +26,7 @@ pub struct SendDocument<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendDocument<'_> {
|
||||
impl Request for SendDocument {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -57,13 +57,13 @@ impl Request for SendDocument<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendDocument<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, document: InputFile) -> Self
|
||||
impl SendDocument {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, document: InputFile) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
document,
|
||||
thumb: None,
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send a game.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendgame).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SendGame<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendGame {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: i32,
|
||||
game_short_name: String,
|
||||
disable_notification: Option<bool>,
|
||||
|
@ -24,7 +24,7 @@ pub struct SendGame<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendGame<'_> {
|
||||
impl Request for SendGame {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -38,14 +38,18 @@ impl Request for SendGame<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendGame<'a> {
|
||||
pub(crate) fn new<G>(bot: &'a Bot, chat_id: i32, game_short_name: G) -> Self
|
||||
impl SendGame {
|
||||
pub(crate) fn new<G>(
|
||||
bot: Arc<Bot>,
|
||||
chat_id: i32,
|
||||
game_short_name: G,
|
||||
) -> Self
|
||||
where
|
||||
G: Into<String>,
|
||||
{
|
||||
let game_short_name = game_short_name.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
game_short_name,
|
||||
disable_notification: None,
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{InlineKeyboardMarkup, LabeledPrice, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send invoices.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendinvoice).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SendInvoice<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendInvoice {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: i32,
|
||||
title: String,
|
||||
description: String,
|
||||
|
@ -42,7 +42,7 @@ pub struct SendInvoice<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendInvoice<'_> {
|
||||
impl Request for SendInvoice {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -56,10 +56,10 @@ impl Request for SendInvoice<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendInvoice<'a> {
|
||||
impl SendInvoice {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn new<T, D, Pl, Pt, S, C, Pr>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: i32,
|
||||
title: T,
|
||||
description: D,
|
||||
|
@ -86,7 +86,7 @@ impl<'a> SendInvoice<'a> {
|
|||
let currency = currency.into();
|
||||
let prices = prices.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
title,
|
||||
description,
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send point on the map.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendlocation).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SendLocation<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendLocation {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
latitude: f32,
|
||||
longitude: f32,
|
||||
|
@ -26,7 +26,7 @@ pub struct SendLocation<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendLocation<'_> {
|
||||
impl Request for SendLocation {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -40,9 +40,9 @@ impl Request for SendLocation<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendLocation<'a> {
|
||||
impl SendLocation {
|
||||
pub(crate) fn new<C>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
latitude: f32,
|
||||
longitude: f32,
|
||||
|
@ -52,7 +52,7 @@ impl<'a> SendLocation<'a> {
|
|||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
latitude,
|
||||
longitude,
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
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(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct SendMediaGroup<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendMediaGroup {
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
media: Vec<InputMedia>, // TODO: InputMediaPhoto and InputMediaVideo
|
||||
disable_notification: Option<bool>,
|
||||
|
@ -19,7 +19,7 @@ pub struct SendMediaGroup<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendMediaGroup<'_> {
|
||||
impl Request for SendMediaGroup {
|
||||
type Output = Vec<Message>;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Vec<Message>> {
|
||||
|
@ -42,8 +42,8 @@ impl Request for SendMediaGroup<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendMediaGroup<'a> {
|
||||
pub(crate) fn new<C, M>(bot: &'a Bot, chat_id: C, media: M) -> Self
|
||||
impl SendMediaGroup {
|
||||
pub(crate) fn new<C, M>(bot: Arc<Bot>, chat_id: C, media: M) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
M: Into<Vec<InputMedia>>,
|
||||
|
@ -51,7 +51,7 @@ impl<'a> SendMediaGroup<'a> {
|
|||
let chat_id = chat_id.into();
|
||||
let media = media.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
media,
|
||||
disable_notification: None,
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send text messages.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendmessage).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SendMessage<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendMessage {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
pub chat_id: ChatId,
|
||||
pub text: String,
|
||||
pub parse_mode: Option<ParseMode>,
|
||||
|
@ -26,7 +26,7 @@ pub struct SendMessage<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendMessage<'_> {
|
||||
impl Request for SendMessage {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -40,14 +40,14 @@ impl Request for SendMessage<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendMessage<'a> {
|
||||
pub(crate) fn new<C, T>(bot: &'a Bot, chat_id: C, text: T) -> Self
|
||||
impl SendMessage {
|
||||
pub(crate) fn new<C, T>(bot: Arc<Bot>, chat_id: C, text: T) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
T: Into<String>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
text: text.into(),
|
||||
parse_mode: None,
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
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(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct SendPhoto<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendPhoto {
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
photo: InputFile,
|
||||
caption: Option<String>,
|
||||
|
@ -22,7 +22,7 @@ pub struct SendPhoto<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendPhoto<'_> {
|
||||
impl Request for SendPhoto {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -51,13 +51,13 @@ impl Request for SendPhoto<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendPhoto<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, photo: InputFile) -> Self
|
||||
impl SendPhoto {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, photo: InputFile) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
photo,
|
||||
caption: None,
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message, PollType, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send a native poll.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendpoll).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SendPoll<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendPoll {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
question: String,
|
||||
options: Vec<String>,
|
||||
|
@ -30,7 +30,7 @@ pub struct SendPoll<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendPoll<'_> {
|
||||
impl Request for SendPoll {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -44,9 +44,9 @@ impl Request for SendPoll<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendPoll<'a> {
|
||||
impl SendPoll {
|
||||
pub(crate) fn new<C, Q, O>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
question: Q,
|
||||
options: O,
|
||||
|
@ -60,7 +60,7 @@ impl<'a> SendPoll<'a> {
|
|||
let question = question.into();
|
||||
let options = options.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
question,
|
||||
options,
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatId, InputFile, Message, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send static .WEBP or [animated] .TGS stickers.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendsticker).
|
||||
///
|
||||
/// [animated]: https://telegram.org/blog/animated-stickers
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct SendSticker<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendSticker {
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
sticker: InputFile,
|
||||
disable_notification: Option<bool>,
|
||||
|
@ -22,7 +22,7 @@ pub struct SendSticker<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendSticker<'_> {
|
||||
impl Request for SendSticker {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -47,13 +47,13 @@ impl Request for SendSticker<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendSticker<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, sticker: InputFile) -> Self
|
||||
impl SendSticker {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, sticker: InputFile) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
sticker,
|
||||
disable_notification: None,
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message, ReplyMarkup},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to send information about a venue.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendvenue).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SendVenue<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SendVenue {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
latitude: f32,
|
||||
longitude: f32,
|
||||
|
@ -29,7 +29,7 @@ pub struct SendVenue<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendVenue<'_> {
|
||||
impl Request for SendVenue {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -43,9 +43,9 @@ impl Request for SendVenue<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendVenue<'a> {
|
||||
impl SendVenue {
|
||||
pub(crate) fn new<C, T, A>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
latitude: f32,
|
||||
longitude: f32,
|
||||
|
@ -61,7 +61,7 @@ impl<'a> SendVenue<'a> {
|
|||
let title = title.into();
|
||||
let address = address.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
latitude,
|
||||
longitude,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
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).
|
||||
|
@ -13,9 +13,9 @@ use crate::{
|
|||
/// limit may be changed in the future.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#sendvideo).
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct SendVideo<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendVideo {
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
video: InputFile,
|
||||
duration: Option<i32>,
|
||||
|
@ -31,7 +31,7 @@ pub struct SendVideo<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendVideo<'_> {
|
||||
impl Request for SendVideo {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -70,13 +70,13 @@ impl Request for SendVideo<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendVideo<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, video: InputFile) -> Self
|
||||
impl SendVideo {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, video: InputFile) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
video,
|
||||
duration: None,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
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.
|
||||
|
@ -12,9 +12,9 @@ use crate::{
|
|||
/// [The official docs](https://core.telegram.org/bots/api#sendvideonote).
|
||||
///
|
||||
/// [v.4.0]: https://telegram.org/blog/video-messages-and-telescope
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct SendVideoNote<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendVideoNote {
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
video_note: InputFile,
|
||||
duration: Option<i32>,
|
||||
|
@ -26,7 +26,7 @@ pub struct SendVideoNote<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendVideoNote<'_> {
|
||||
impl Request for SendVideoNote {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -57,9 +57,9 @@ impl Request for SendVideoNote<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendVideoNote<'a> {
|
||||
impl SendVideoNote {
|
||||
pub(crate) fn new<C>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
video_note: InputFile,
|
||||
) -> Self
|
||||
|
@ -67,7 +67,7 @@ impl<'a> SendVideoNote<'a> {
|
|||
C: Into<ChatId>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
video_note,
|
||||
duration: None,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
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.
|
||||
|
@ -18,9 +18,9 @@ use crate::{
|
|||
///
|
||||
/// [`Audio`]: crate::types::Audio
|
||||
/// [`Document`]: crate::types::Document
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct SendVoice<'a> {
|
||||
bot: BotWrapper<'a>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SendVoice {
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
voice: InputFile,
|
||||
caption: Option<String>,
|
||||
|
@ -32,7 +32,7 @@ pub struct SendVoice<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SendVoice<'_> {
|
||||
impl Request for SendVoice {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -63,13 +63,13 @@ impl Request for SendVoice<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SendVoice<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, voice: InputFile) -> Self
|
||||
impl SendVoice {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, voice: InputFile) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
voice,
|
||||
caption: None,
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
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.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#setchatadministratorcustomtitle).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SetChatAdministratorCustomTitle<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetChatAdministratorCustomTitle {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
custom_title: String,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SetChatAdministratorCustomTitle<'_> {
|
||||
impl Request for SetChatAdministratorCustomTitle {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -37,9 +37,9 @@ impl Request for SetChatAdministratorCustomTitle<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SetChatAdministratorCustomTitle<'a> {
|
||||
impl SetChatAdministratorCustomTitle {
|
||||
pub(crate) fn new<C, CT>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
user_id: i32,
|
||||
custom_title: CT,
|
||||
|
@ -51,7 +51,7 @@ impl<'a> SetChatAdministratorCustomTitle<'a> {
|
|||
let chat_id = chat_id.into();
|
||||
let custom_title = custom_title.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
user_id,
|
||||
custom_title,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to change the description of a group, a supergroup or a
|
||||
/// channel.
|
||||
|
@ -16,16 +16,16 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#setchatdescription).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SetChatDescription<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetChatDescription {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
description: Option<String>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SetChatDescription<'_> {
|
||||
impl Request for SetChatDescription {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -39,14 +39,14 @@ impl Request for SetChatDescription<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SetChatDescription<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self
|
||||
impl SetChatDescription {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
description: None,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, ChatPermissions, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to set default chat permissions for all members.
|
||||
///
|
||||
|
@ -15,16 +15,16 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#setchatpermissions).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SetChatPermissions<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetChatPermissions {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
permissions: ChatPermissions,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SetChatPermissions<'_> {
|
||||
impl Request for SetChatPermissions {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -38,9 +38,9 @@ impl Request for SetChatPermissions<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SetChatPermissions<'a> {
|
||||
impl SetChatPermissions {
|
||||
pub(crate) fn new<C>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
permissions: ChatPermissions,
|
||||
) -> Self
|
||||
|
@ -49,7 +49,7 @@ impl<'a> SetChatPermissions<'a> {
|
|||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
permissions,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, InputFile, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to set a new profile photo for the chat.
|
||||
///
|
||||
|
@ -15,16 +15,16 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#setchatphoto).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SetChatPhoto<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetChatPhoto {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
photo: InputFile,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SetChatPhoto<'_> {
|
||||
impl Request for SetChatPhoto {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -38,14 +38,14 @@ impl Request for SetChatPhoto<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SetChatPhoto<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, photo: InputFile) -> Self
|
||||
impl SetChatPhoto {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, photo: InputFile) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
photo,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to set a new group sticker set for a supergroup.
|
||||
///
|
||||
|
@ -16,16 +16,16 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#setchatstickerset).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SetChatStickerSet<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetChatStickerSet {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
sticker_set_name: String,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SetChatStickerSet<'_> {
|
||||
impl Request for SetChatStickerSet {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -39,9 +39,9 @@ impl Request for SetChatStickerSet<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SetChatStickerSet<'a> {
|
||||
impl SetChatStickerSet {
|
||||
pub(crate) fn new<C, S>(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: C,
|
||||
sticker_set_name: S,
|
||||
) -> Self
|
||||
|
@ -52,7 +52,7 @@ impl<'a> SetChatStickerSet<'a> {
|
|||
let chat_id = chat_id.into();
|
||||
let sticker_set_name = sticker_set_name.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
sticker_set_name,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to change the title of a chat.
|
||||
///
|
||||
|
@ -15,16 +15,16 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#setchattitle).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SetChatTitle<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetChatTitle {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
title: String,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SetChatTitle<'_> {
|
||||
impl Request for SetChatTitle {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -38,8 +38,8 @@ impl Request for SetChatTitle<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SetChatTitle<'a> {
|
||||
pub(crate) fn new<C, T>(bot: &'a Bot, chat_id: C, title: T) -> Self
|
||||
impl SetChatTitle {
|
||||
pub(crate) fn new<C, T>(bot: Arc<Bot>, chat_id: C, title: T) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
T: Into<String>,
|
||||
|
@ -47,7 +47,7 @@ impl<'a> SetChatTitle<'a> {
|
|||
let chat_id = chat_id.into();
|
||||
let title = title.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
title,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to set the score of the specified user in a game.
|
||||
///
|
||||
|
@ -20,10 +20,10 @@ use crate::{
|
|||
/// [`Message`]: crate::types::Message
|
||||
/// [`True`]: crate::types::True
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SetGameScore<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetGameScore {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
user_id: i32,
|
||||
|
@ -33,7 +33,7 @@ pub struct SetGameScore<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SetGameScore<'_> {
|
||||
impl Request for SetGameScore {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -47,15 +47,15 @@ impl Request for SetGameScore<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SetGameScore<'a> {
|
||||
impl SetGameScore {
|
||||
pub(crate) fn new(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
user_id: i32,
|
||||
score: i32,
|
||||
) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_or_inline_message,
|
||||
user_id,
|
||||
score,
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
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.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#setstickerpositioninset).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SetStickerPositionInSet<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetStickerPositionInSet {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
sticker: String,
|
||||
position: i32,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SetStickerPositionInSet<'_> {
|
||||
impl Request for SetStickerPositionInSet {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -36,14 +36,14 @@ impl Request for SetStickerPositionInSet<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SetStickerPositionInSet<'a> {
|
||||
pub(crate) fn new<S>(bot: &'a Bot, sticker: S, position: i32) -> Self
|
||||
impl SetStickerPositionInSet {
|
||||
pub(crate) fn new<S>(bot: Arc<Bot>, sticker: S, position: i32) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
let sticker = sticker.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
sticker,
|
||||
position,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{AllowedUpdate, InputFile, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to specify a url and receive incoming updates via an
|
||||
/// outgoing webhook.
|
||||
|
@ -25,10 +25,10 @@ use crate::{
|
|||
///
|
||||
/// [`Update`]: crate::types::Update
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct SetWebhook<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SetWebhook {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
url: String,
|
||||
certificate: Option<InputFile>,
|
||||
max_connections: Option<i32>,
|
||||
|
@ -36,7 +36,7 @@ pub struct SetWebhook<'a> {
|
|||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for SetWebhook<'_> {
|
||||
impl Request for SetWebhook {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -50,14 +50,14 @@ impl Request for SetWebhook<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> SetWebhook<'a> {
|
||||
pub(crate) fn new<U>(bot: &'a Bot, url: U) -> Self
|
||||
impl SetWebhook {
|
||||
pub(crate) fn new<U>(bot: Arc<Bot>, url: U) -> Self
|
||||
where
|
||||
U: Into<String>,
|
||||
{
|
||||
let url = url.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
url,
|
||||
certificate: None,
|
||||
max_connections: None,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to stop updating a live location message before
|
||||
/// `live_period` expires.
|
||||
|
@ -19,17 +19,17 @@ use crate::{
|
|||
/// [`Message`]: crate::types::Message
|
||||
/// [`True`]: crate::types::True
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct StopMessageLiveLocation<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct StopMessageLiveLocation {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
#[serde(flatten)]
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
reply_markup: Option<InlineKeyboardMarkup>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for StopMessageLiveLocation<'_> {
|
||||
impl Request for StopMessageLiveLocation {
|
||||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
|
@ -43,13 +43,13 @@ impl Request for StopMessageLiveLocation<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> StopMessageLiveLocation<'a> {
|
||||
impl StopMessageLiveLocation {
|
||||
pub(crate) fn new(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
chat_or_inline_message: ChatOrInlineMessage,
|
||||
) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_or_inline_message,
|
||||
reply_markup: None,
|
||||
}
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, InlineKeyboardMarkup, Poll},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to stop a poll which was sent by the bot.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#stoppoll).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct StopPoll<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct StopPoll {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
message_id: i32,
|
||||
reply_markup: Option<InlineKeyboardMarkup>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for StopPoll<'_> {
|
||||
impl Request for StopPoll {
|
||||
type Output = Poll;
|
||||
|
||||
/// On success, the stopped [`Poll`] with the final results is returned.
|
||||
|
@ -38,14 +38,14 @@ impl Request for StopPoll<'_> {
|
|||
.await
|
||||
}
|
||||
}
|
||||
impl<'a> StopPoll<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, message_id: i32) -> Self
|
||||
impl StopPoll {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, message_id: i32) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
message_id,
|
||||
reply_markup: None,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
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,
|
||||
|
@ -15,16 +15,16 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#unbanchatmember).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct UnbanChatMember<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct UnbanChatMember {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
user_id: i32,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for UnbanChatMember<'_> {
|
||||
impl Request for UnbanChatMember {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -38,14 +38,14 @@ impl Request for UnbanChatMember<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> UnbanChatMember<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C, user_id: i32) -> Self
|
||||
impl UnbanChatMember {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C, user_id: i32) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
chat_id,
|
||||
user_id,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Use this method to unpin a message in a group, a supergroup, or a channel.
|
||||
///
|
||||
|
@ -16,15 +16,15 @@ use crate::{
|
|||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#unpinchatmessage).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct UnpinChatMessage<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct UnpinChatMessage {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for UnpinChatMessage<'_> {
|
||||
impl Request for UnpinChatMessage {
|
||||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
|
@ -38,16 +38,13 @@ impl Request for UnpinChatMessage<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> UnpinChatMessage<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self
|
||||
impl UnpinChatMessage {
|
||||
pub(crate) fn new<C>(bot: Arc<Bot>, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
let chat_id = chat_id.into();
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
chat_id,
|
||||
}
|
||||
Self { bot, chat_id }
|
||||
}
|
||||
|
||||
/// Unique identifier for the target chat or username of the target channel
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
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
|
||||
|
@ -17,15 +17,15 @@ use crate::{
|
|||
/// [`Bot::create_new_sticker_set`]: crate::Bot::create_new_sticker_set
|
||||
/// [`Bot::add_sticker_to_set`]: crate::Bot::add_sticker_to_set
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize)]
|
||||
pub struct UploadStickerFile<'a> {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct UploadStickerFile {
|
||||
#[serde(skip_serializing)]
|
||||
bot: BotWrapper<'a>,
|
||||
bot: Arc<Bot>,
|
||||
user_id: i32,
|
||||
png_sticker: InputFile,
|
||||
}
|
||||
#[async_trait::async_trait]
|
||||
impl Request for UploadStickerFile<'_> {
|
||||
impl Request for UploadStickerFile {
|
||||
type Output = File;
|
||||
|
||||
async fn send(&self) -> ResponseResult<File> {
|
||||
|
@ -39,14 +39,14 @@ impl Request for UploadStickerFile<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> UploadStickerFile<'a> {
|
||||
impl UploadStickerFile {
|
||||
pub(crate) fn new(
|
||||
bot: &'a Bot,
|
||||
bot: Arc<Bot>,
|
||||
user_id: i32,
|
||||
png_sticker: InputFile,
|
||||
) -> Self {
|
||||
Self {
|
||||
bot: BotWrapper(bot),
|
||||
bot,
|
||||
user_id,
|
||||
png_sticker,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue