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