Fix the docs of several requests

This commit is contained in:
Temirkhan Myrzamadi 2020-01-21 01:03:03 +06:00
parent 032de7bc67
commit 81167ff44d
12 changed files with 194 additions and 146 deletions

View file

@ -7,27 +7,16 @@ use crate::{
use crate::requests::{Request, ResponseResult}; use crate::requests::{Request, ResponseResult};
/// Use this method to add a new sticker to a set created by the bot. Returns /// Use this method to add a new sticker to a set created by the bot.
/// True on success. ///
/// [The official docs](https://core.telegram.org/bots/api#addstickertoset).
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct AddStickerToSet<'a> { pub struct AddStickerToSet<'a> {
bot: &'a Bot, bot: &'a Bot,
/// User identifier of sticker set owner
user_id: i32, user_id: i32,
/// Sticker set name
name: String, name: String,
/// Png image with the sticker, must be up to 512 kilobytes in size,
/// dimensions must not exceed 512px, and either width or height must be
/// exactly 512px. Pass a file_id as a String to send a file that already
/// exists on the Telegram servers, pass an HTTP URL as a String for
/// Telegram to get a file from the Internet, or upload a new one using
/// multipart/form-data. More info on Sending Files »
png_sticker: InputFile, png_sticker: InputFile,
/// One or more emoji corresponding to the sticker
emojis: String, emojis: String,
/// A JSON-serialized object for position where the mask should be placed
/// on faces
mask_position: Option<MaskPosition>, mask_position: Option<MaskPosition>,
} }
@ -79,11 +68,13 @@ impl<'a> AddStickerToSet<'a> {
} }
} }
/// User identifier of sticker set owner.
pub fn user_id(mut self, val: i32) -> Self { pub fn user_id(mut self, val: i32) -> Self {
self.user_id = val; self.user_id = val;
self self
} }
/// Sticker set name.
pub fn name<T>(mut self, val: T) -> Self pub fn name<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -92,11 +83,20 @@ impl<'a> AddStickerToSet<'a> {
self self
} }
/// **Png** image with the sticker, must be up to 512 kilobytes in size,
/// dimensions must not exceed 512px, and either width or height must be
/// exactly 512px. Pass a file_id as a String to send a file that already
/// exists on the Telegram servers, pass an HTTP URL as a String for
/// Telegram to get a file from the Internet, or upload a new one using
/// multipart/form-data. [More info on Sending Files »].
///
/// [More info on Sending Files »]: https://core.telegram.org/bots/api#sending-files
pub fn png_sticker(mut self, val: InputFile) -> Self { pub fn png_sticker(mut self, val: InputFile) -> Self {
self.png_sticker = val; self.png_sticker = val;
self self
} }
/// One or more emoji corresponding to the sticker.
pub fn emojis<T>(mut self, val: T) -> Self pub fn emojis<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -105,6 +105,8 @@ impl<'a> AddStickerToSet<'a> {
self self
} }
/// A JSON-serialized object for position where the mask should be placed on
/// faces.
pub fn mask_position(mut self, val: MaskPosition) -> Self { pub fn mask_position(mut self, val: MaskPosition) -> Self {
self.mask_position = Some(val); self.mask_position = Some(val);
self self

View file

@ -7,36 +7,22 @@ use crate::{
Bot, Bot,
}; };
/// 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. The answer will be displayed to the user as a notification at the /// keyboards]. The answer will be displayed to the user as a notification at
/// top of the chat screen or as an alert. On success, True is /// the top of the chat screen or as an alert.
/// returned.Alternatively, the user can be redirected to the specified Game ///
/// URL. For this option to work, you must first create a game for your bot via /// [The official docs](https://core.telegram.org/bots/api#answercallbackquery).
/// @Botfather and accept the terms. Otherwise, you may use links like ///
/// t.me/your_bot?start=XXXX that open your bot with a parameter. /// [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(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct AnswerCallbackQuery<'a> { pub struct AnswerCallbackQuery<'a> {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: &'a Bot, bot: &'a Bot,
/// Unique identifier for the query to be answered
callback_query_id: String, callback_query_id: String,
/// Text of the notification. If not specified, nothing will be shown to
/// the user, 0-200 characters
text: Option<String>, text: Option<String>,
/// If true, an alert will be shown by the client instead of a notification
/// at the top of the chat screen. Defaults to false.
show_alert: Option<bool>, show_alert: Option<bool>,
/// URL that will be opened by the user's client. If you have created a
/// Game and accepted the conditions via @Botfather, specify the URL that
/// opens your game note that this will only work if the query comes from
/// a callback_game button.Otherwise, you may use links like
/// t.me/your_bot?start=XXXX that open your bot with a parameter.
url: Option<String>, url: Option<String>,
/// The maximum amount of time in seconds that the result of the callback
/// query may be cached client-side. Telegram apps will support caching
/// starting in version 3.14. Defaults to 0.
cache_time: Option<i32>, cache_time: Option<i32>,
} }
@ -71,6 +57,7 @@ impl<'a> AnswerCallbackQuery<'a> {
} }
} }
/// Unique identifier for the query to be answered.
pub fn callback_query_id<T>(mut self, val: T) -> Self pub fn callback_query_id<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -79,6 +66,8 @@ impl<'a> AnswerCallbackQuery<'a> {
self self
} }
/// Text of the notification. If not specified, nothing will be shown to the
/// user, 0-200 characters.
pub fn text<T>(mut self, val: T) -> Self pub fn text<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -87,11 +76,24 @@ impl<'a> AnswerCallbackQuery<'a> {
self self
} }
/// If `true`, an alert will be shown by the client instead of a
/// notification at the top of the chat screen. Defaults to `false`.
pub fn show_alert(mut self, val: bool) -> Self { pub fn show_alert(mut self, val: bool) -> Self {
self.show_alert = Some(val); self.show_alert = Some(val);
self self
} }
/// URL that will be opened by the user's client. If you have created a
/// [`Game`] and accepted the conditions via [@Botfather], specify the
/// URL that opens your game note that this will only work if the
/// query comes from a [`callback_game`] button.
///
/// Otherwise, you may use links like `t.me/your_bot?start=XXXX` that open
/// your bot with a parameter.
///
/// [@Botfather]: https://t.me/botfather
/// [`callback_game`]: crate::types::InlineKeyboardButton
/// [`Game`]: crate::types::Game
pub fn url<T>(mut self, val: T) -> Self pub fn url<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -100,6 +102,9 @@ impl<'a> AnswerCallbackQuery<'a> {
self self
} }
/// The maximum amount of time in seconds that the result of the callback
/// query may be cached client-side. Telegram apps will support caching
/// starting in version 3.14. Defaults to 0.
pub fn cache_time(mut self, val: i32) -> Self { pub fn cache_time(mut self, val: i32) -> Self {
self.cache_time = Some(val); self.cache_time = Some(val);
self self

View file

@ -7,45 +7,22 @@ use crate::{
Bot, Bot,
}; };
/// Use this method to send answers to an inline query. On success, True is /// Use this method to send answers to an inline query.
/// returned.No more than 50 results per query are allowed. ///
/// No more than **50** results per query are allowed.
///
/// [The official docs](https://core.telegram.org/bots/api#answerinlinequery).
#[serde_with_macros::skip_serializing_none] #[serde_with_macros::skip_serializing_none]
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct AnswerInlineQuery<'a> { pub struct AnswerInlineQuery<'a> {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: &'a Bot, bot: &'a Bot,
/// Unique identifier for the answered query
inline_query_id: String, inline_query_id: String,
/// A JSON-serialized array of results for the inline query
results: Vec<InlineQueryResult>, results: Vec<InlineQueryResult>,
/// The maximum amount of time in seconds that the result of the inline
/// query may be cached on the server. Defaults to 300.
cache_time: Option<i32>, cache_time: Option<i32>,
/// Pass True, if results may be cached on the server side only for the
/// user that sent the query. By default, results may be returned to any
/// user who sends the same query
is_personal: Option<bool>, is_personal: Option<bool>,
/// Pass the offset that a client should send in the next query with the
/// same text to receive more results. Pass an empty string if there are no
/// more results or if you dont support pagination. Offset length cant
/// exceed 64 bytes.
next_offset: Option<String>, next_offset: Option<String>,
/// If passed, clients will display a button with specified text that
/// switches the user to a private chat with the bot and sends the bot a
/// start message with the parameter switch_pm_parameter
switch_pm_text: Option<String>, switch_pm_text: Option<String>,
/// Deep-linking parameter for the /start message sent to the bot when user
/// presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and -
/// are allowed.Example: An inline bot that sends YouTube videos can ask
/// the user to connect the bot to their YouTube account to adapt search
/// results accordingly. To do this, it displays a Connect your YouTube
/// account button above the results, or even before showing any. The user
/// presses the button, switches to a private chat with the bot and, in
/// doing so, passes a start parameter that instructs the bot to return an
/// oauth link. Once done, the bot can offer a switch_inline button so that
/// the user can easily return to the chat where they wanted to use the
/// bot's inline capabilities.
switch_pm_parameter: Option<String>, switch_pm_parameter: Option<String>,
} }
@ -88,6 +65,7 @@ impl<'a> AnswerInlineQuery<'a> {
} }
} }
/// Unique identifier for the answered query/
pub fn inline_query_id<T>(mut self, val: T) -> Self pub fn inline_query_id<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -96,6 +74,7 @@ impl<'a> AnswerInlineQuery<'a> {
self self
} }
/// A JSON-serialized array of results for the inline query.
pub fn results<T>(mut self, val: T) -> Self pub fn results<T>(mut self, val: T) -> Self
where where
T: Into<Vec<InlineQueryResult>>, T: Into<Vec<InlineQueryResult>>,
@ -104,17 +83,26 @@ impl<'a> AnswerInlineQuery<'a> {
self self
} }
/// The maximum amount of time in seconds that the result of the inline
/// query may be cached on the server. Defaults to 300.
pub fn cache_time(mut self, val: i32) -> Self { pub fn cache_time(mut self, val: i32) -> Self {
self.cache_time = Some(val); self.cache_time = Some(val);
self self
} }
/// Pass `true`, if results may be cached on the server side only for the
/// user that sent the query. By default, results may be returned to any
/// user who sends the same query.
#[allow(clippy::wrong_self_convention)] #[allow(clippy::wrong_self_convention)]
pub fn is_personal(mut self, val: bool) -> Self { pub fn is_personal(mut self, val: bool) -> Self {
self.is_personal = Some(val); self.is_personal = Some(val);
self self
} }
/// Pass the offset that a client should send in the next query with the
/// same text to receive more results. Pass an empty string if there are no
/// more results or if you dont support pagination. Offset length cant
/// exceed 64 bytes.
pub fn next_offset<T>(mut self, val: T) -> Self pub fn next_offset<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -123,6 +111,12 @@ impl<'a> AnswerInlineQuery<'a> {
self self
} }
/// If passed, clients will display a button with specified text that
/// switches the user to a private chat with the bot and sends the bot a
/// start message with the parameter [`switch_pm_parameter`].
///
/// [`switch_pm_parameter`]:
/// crate::requests::AnswerInlineQuery::switch_pm_parameter
pub fn switch_pm_text<T>(mut self, val: T) -> Self pub fn switch_pm_text<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -131,6 +125,22 @@ impl<'a> AnswerInlineQuery<'a> {
self self
} }
/// [Deep-linking] parameter for the /start message sent to the bot when
/// user presses the switch button. 1-64 characters, only `A-Z`, `a-z`,
/// `0-9`, `_` and `-` are allowed.
///
/// Example: An inline bot that sends YouTube videos can ask the user to
/// connect the bot to their YouTube account to adapt search results
/// accordingly. To do this, it displays a Connect your YouTube account
/// button above the results, or even before showing any. The user presses
/// the button, switches to a private chat with the bot and, in doing so,
/// passes a start parameter that instructs the bot to return an oauth link.
/// Once done, the bot can offer a [`switch_inline`] button so that the user
/// can easily return to the chat where they wanted to use the bot's
/// inline capabilities.
///
/// [Deep-linking]: https://core.telegram.org/bots#deep-linking
/// [`switch_inline`]: crate::types::InlineKeyboardMarkup
pub fn switch_pm_parameter<T>(mut self, val: T) -> Self pub fn switch_pm_parameter<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,

View file

@ -8,28 +8,21 @@ use crate::{
}; };
/// 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
/// pre_checkout_query. Use this method to respond to such pre-checkout queries. /// `pre_checkout_query`. Use this method to respond to such pre-checkout
/// On success, True is returned. Note: The Bot API must receive an answer /// queries. Note: The Bot API must receive an answer within 10 seconds after
/// within 10 seconds after the pre-checkout query was sent. /// the pre-checkout query was sent.
///
/// [The official docs](https://core.telegram.org/bots/api#answerprecheckoutquery).
///
/// [`Update`]: crate::types::Update
#[serde_with_macros::skip_serializing_none] #[serde_with_macros::skip_serializing_none]
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct AnswerPreCheckoutQuery<'a> { pub struct AnswerPreCheckoutQuery<'a> {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: &'a Bot, bot: &'a Bot,
/// Unique identifier for the query to be answered
pre_checkout_query_id: String, pre_checkout_query_id: String,
/// Specify True if everything is alright (goods are available, etc.) and
/// the bot is ready to proceed with the order. Use False if there are any
/// problems.
ok: bool, ok: bool,
/// Required if ok is False. Error message in human readable form that
/// explains the reason for failure to proceed with the checkout (e.g.
/// "Sorry, somebody just bought the last of our amazing black T-shirts
/// while you were busy filling out your payment details. Please choose a
/// different color or garment!"). Telegram will display this message to
/// the user.
error_message: Option<String>, error_message: Option<String>,
} }
@ -66,6 +59,7 @@ impl<'a> AnswerPreCheckoutQuery<'a> {
} }
} }
/// Unique identifier for the query to be answered.
pub fn pre_checkout_query_id<T>(mut self, val: T) -> Self pub fn pre_checkout_query_id<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -74,11 +68,20 @@ impl<'a> AnswerPreCheckoutQuery<'a> {
self self
} }
/// Specify `true` if everything is alright (goods are available, etc.) and
/// the bot is ready to proceed with the order. Use False if there are any
/// problems.
pub fn ok(mut self, val: bool) -> Self { pub fn ok(mut self, val: bool) -> Self {
self.ok = val; self.ok = val;
self self
} }
/// Required if ok is `false`. Error message in human readable form that
/// explains the reason for failure to proceed with the checkout (e.g.
/// "Sorry, somebody just bought the last of our amazing black T-shirts
/// while you were busy filling out your payment details. Please choose a
/// different color or garment!"). Telegram will display this message to the
/// user.
pub fn error_message<T>(mut self, val: T) -> Self pub fn error_message<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,

View file

@ -8,28 +8,21 @@ use crate::{
}; };
/// 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
/// queries. On success, True is returned. /// queries.
///
/// [The official docs](https://core.telegram.org/bots/api#answershippingquery).
///
/// [`Update`]: crate::types::Update
#[serde_with_macros::skip_serializing_none] #[serde_with_macros::skip_serializing_none]
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct AnswerShippingQuery<'a> { pub struct AnswerShippingQuery<'a> {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: &'a Bot, bot: &'a Bot,
/// Unique identifier for the query to be answered
shipping_query_id: String, shipping_query_id: String,
/// Specify True if delivery to the specified address is possible and False
/// if there are any problems (for example, if delivery to the specified
/// address is not possible)
ok: bool, ok: bool,
/// Required if ok is True. A JSON-serialized array of available shipping
/// options.
shipping_options: Option<Vec<ShippingOption>>, shipping_options: Option<Vec<ShippingOption>>,
/// Required if ok is False. Error message in human readable form that
/// explains why it is impossible to complete the order (e.g. "Sorry,
/// delivery to your desired address is unavailable'). Telegram will
/// display this message to the user.
error_message: Option<String>, error_message: Option<String>,
} }
@ -63,6 +56,7 @@ impl<'a> AnswerShippingQuery<'a> {
} }
} }
/// Unique identifier for the query to be answered.
pub fn shipping_query_id<T>(mut self, val: T) -> Self pub fn shipping_query_id<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -71,11 +65,16 @@ impl<'a> AnswerShippingQuery<'a> {
self self
} }
/// Specify `true` if delivery to the specified address is possible and
/// False if there are any problems (for example, if delivery to the
/// specified address is not possible).
pub fn ok(mut self, val: bool) -> Self { pub fn ok(mut self, val: bool) -> Self {
self.ok = val; self.ok = val;
self self
} }
/// Required if ok is `true`. A JSON-serialized array of available shipping
/// options.
pub fn shipping_options<T>(mut self, val: T) -> Self pub fn shipping_options<T>(mut self, val: T) -> Self
where where
T: Into<Vec<ShippingOption>>, T: Into<Vec<ShippingOption>>,
@ -84,6 +83,10 @@ impl<'a> AnswerShippingQuery<'a> {
self self
} }
/// Required if ok is `false`. Error message in human readable form that
/// explains why it is impossible to complete the order (e.g. "Sorry,
/// delivery to your desired address is unavailable'). Telegram will display
/// this message to the user.
pub fn error_message<T>(mut self, val: T) -> Self pub fn error_message<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,

View file

@ -6,34 +6,18 @@ use crate::{
}; };
/// 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. Returns True on success. /// able to edit the created sticker set.
///
/// [The official docs](https://core.telegram.org/bots/api#createnewstickerset).
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct CreateNewStickerSet<'a> { pub struct CreateNewStickerSet<'a> {
bot: &'a Bot, bot: &'a Bot,
/// User identifier of created sticker set owner
user_id: i32, user_id: i32,
/// Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g.,
/// animals). Can contain only english letters, digits and underscores.
/// Must begin with a letter, can't contain consecutive underscores and
/// must end in “_by_<bot username>”. <bot_username> is case insensitive.
/// 1-64 characters.
name: String, name: String,
/// Sticker set title, 1-64 characters
title: String, title: String,
/// Png image with the sticker, must be up to 512 kilobytes in size,
/// dimensions must not exceed 512px, and either width or height must be
/// exactly 512px. Pass a file_id as a String to send a file that already
/// exists on the Telegram servers, pass an HTTP URL as a String for
/// Telegram to get a file from the Internet, or upload a new one using
/// multipart/form-data. More info on Sending Files »
png_sticker: InputFile, png_sticker: InputFile,
/// One or more emoji corresponding to the sticker
emojis: String, emojis: String,
/// Pass True, if a set of mask stickers should be created
contains_masks: Option<bool>, contains_masks: Option<bool>,
/// A JSON-serialized object for position where the mask should be placed
/// on faces
mask_position: Option<MaskPosition>, mask_position: Option<MaskPosition>,
} }
@ -93,11 +77,17 @@ impl<'a> CreateNewStickerSet<'a> {
} }
} }
/// User identifier of created sticker set owner.
pub fn user_id(mut self, val: i32) -> Self { pub fn user_id(mut self, val: i32) -> Self {
self.user_id = val; self.user_id = val;
self self
} }
/// Short name of sticker set, to be used in `t.me/addstickers/` URLs (e.g.,
/// animals). Can contain only english letters, digits and underscores. Must
/// begin with a letter, can't contain consecutive underscores and must end
/// in `_by_<bot username>`. `<bot_username>` is case insensitive. 1-64
/// characters.
pub fn name<T>(mut self, val: T) -> Self pub fn name<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -106,6 +96,7 @@ impl<'a> CreateNewStickerSet<'a> {
self self
} }
/// Sticker set title, 1-64 characters.
pub fn title<T>(mut self, val: T) -> Self pub fn title<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -114,11 +105,20 @@ impl<'a> CreateNewStickerSet<'a> {
self self
} }
/// **Png** image with the sticker, must be up to 512 kilobytes in size,
/// dimensions must not exceed 512px, and either width or height must be
/// exactly 512px. Pass a file_id as a String to send a file that already
/// exists on the Telegram servers, pass an HTTP URL as a String for
/// Telegram to get a file from the Internet, or upload a new one using
/// multipart/form-data. [More info on Sending Files »].
///
/// [More info on Sending Files »]: https://core.telegram.org/bots/api#sending-files
pub fn png_sticker(mut self, val: InputFile) -> Self { pub fn png_sticker(mut self, val: InputFile) -> Self {
self.png_sticker = val; self.png_sticker = val;
self self
} }
/// One or more emoji corresponding to the sticker.
pub fn emojis<T>(mut self, val: T) -> Self pub fn emojis<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -127,11 +127,14 @@ impl<'a> CreateNewStickerSet<'a> {
self self
} }
/// Pass `true`, if a set of mask stickers should be created.
pub fn contains_masks(mut self, val: bool) -> Self { pub fn contains_masks(mut self, val: bool) -> Self {
self.contains_masks = Some(val); self.contains_masks = Some(val);
self self
} }
/// A JSON-serialized object for position where the mask should be placed on
/// faces.
pub fn mask_position(mut self, val: MaskPosition) -> Self { pub fn mask_position(mut self, val: MaskPosition) -> Self {
self.mask_position = Some(val); self.mask_position = Some(val);
self self

View file

@ -9,15 +9,14 @@ use crate::{
/// 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
/// must have the appropriate admin rights. Returns True on success. /// must have the appropriate admin rights.
///
/// [The official docs](https://core.telegram.org/bots/api#deletechatphoto).
#[serde_with_macros::skip_serializing_none] #[serde_with_macros::skip_serializing_none]
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct DeleteChatPhoto<'a> { pub struct DeleteChatPhoto<'a> {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: &'a Bot, bot: &'a Bot,
/// Unique identifier for the target chat or username of the target channel
/// (in the format @channelusername)
chat_id: ChatId, chat_id: ChatId,
} }
@ -45,6 +44,8 @@ impl<'a> DeleteChatPhoto<'a> {
Self { bot, chat_id } Self { bot, chat_id }
} }
/// Unique identifier for the target chat or username of the target channel
/// (in the format `@channelusername`).
pub fn chat_id<T>(mut self, val: T) -> Self pub fn chat_id<T>(mut self, val: T) -> Self
where where
T: Into<ChatId>, T: Into<ChatId>,

View file

@ -9,17 +9,18 @@ use crate::{
/// Use this method to delete a group sticker set from a supergroup. The bot /// Use this method to delete a group sticker set from a supergroup. The bot
/// must be an administrator in the chat for this to work and must have the /// must be an administrator in the chat for this to work and must have the
/// appropriate admin rights. Use the field can_set_sticker_set optionally /// appropriate admin rights. Use the field `can_set_sticker_set` optionally
/// returned in getChat requests to check if the bot can use this method. /// returned in [`Bot::get_chat`] requests to check if the bot can use this
/// Returns True on success. /// method.
///
/// [The official docs](https://core.telegram.org/bots/api#deletechatstickerset).
///
/// [`Bot::get_chat`]: crate::Bot::get_chat
#[serde_with_macros::skip_serializing_none] #[serde_with_macros::skip_serializing_none]
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct DeleteChatStickerSet<'a> { pub struct DeleteChatStickerSet<'a> {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: &'a Bot, bot: &'a Bot,
/// Unique identifier for the target chat or username of the target
/// supergroup (in the format @supergroupusername)
chat_id: ChatId, chat_id: ChatId,
} }
@ -47,6 +48,8 @@ impl<'a> DeleteChatStickerSet<'a> {
Self { bot, chat_id } Self { bot, chat_id }
} }
/// Unique identifier for the target chat or username of the target
/// supergroup (in the format `@supergroupusername`).
pub fn chat_id<T>(mut self, val: T) -> Self pub fn chat_id<T>(mut self, val: T) -> Self
where where
T: Into<ChatId>, T: Into<ChatId>,

View file

@ -7,25 +7,27 @@ use crate::{
Bot, Bot,
}; };
/// Use this method to delete a message, including service messages, with the /// Use this method to delete a message, including service messages.
/// following limitations:- A message can only be deleted if it was sent less ///
/// than 48 hours ago.- Bots can delete outgoing messages in private chats, /// The limitations are:
/// groups, and supergroups.- Bots can delete incoming messages in private /// - A message can only be deleted if it was sent less than 48 hours ago.
/// chats.- Bots granted can_post_messages permissions can delete outgoing /// - Bots can delete outgoing messages in private chats, groups, and
/// messages in channels.- If the bot is an administrator of a group, it can /// supergroups.
/// delete any message there.- If the bot has can_delete_messages permission in /// - Bots can delete incoming messages in private chats.
/// a supergroup or a channel, it can delete any message there.Returns True on /// - Bots granted can_post_messages permissions can delete outgoing messages
/// success. /// in channels.
/// - If the bot is an administrator of a group, it can delete any message
/// there.
/// - If the bot has can_delete_messages permission in a supergroup or a
/// channel, it can delete any message there.
///
/// [The official docs](https://core.telegram.org/bots/api#deletemessage).
#[serde_with_macros::skip_serializing_none] #[serde_with_macros::skip_serializing_none]
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct DeleteMessage<'a> { pub struct DeleteMessage<'a> {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: &'a Bot, bot: &'a Bot,
/// Unique identifier for the target chat or username of the target channel
/// (in the format @channelusername)
chat_id: ChatId, chat_id: ChatId,
/// Identifier of the message to delete
message_id: i32, message_id: i32,
} }
@ -57,6 +59,8 @@ impl<'a> DeleteMessage<'a> {
} }
} }
/// Unique identifier for the target chat or username of the target channel
/// (in the format `@channelusername`).
pub fn chat_id<T>(mut self, val: T) -> Self pub fn chat_id<T>(mut self, val: T) -> Self
where where
T: Into<ChatId>, T: Into<ChatId>,
@ -65,6 +69,7 @@ impl<'a> DeleteMessage<'a> {
self self
} }
/// Identifier of the message to delete.
pub fn message_id(mut self, val: i32) -> Self { pub fn message_id(mut self, val: i32) -> Self {
self.message_id = val; self.message_id = val;
self self

View file

@ -7,15 +7,14 @@ use crate::{
Bot, Bot,
}; };
/// Use this method to delete a sticker from a set created by the bot. Returns /// Use this method to delete a sticker from a set created by the bot.
/// True on success. ///
/// [The official docs](https://core.telegram.org/bots/api#deletestickerfromset).
#[serde_with_macros::skip_serializing_none] #[serde_with_macros::skip_serializing_none]
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct DeleteStickerFromSet<'a> { pub struct DeleteStickerFromSet<'a> {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: &'a Bot, bot: &'a Bot,
/// File identifier of the sticker
sticker: String, sticker: String,
} }
@ -43,6 +42,7 @@ impl<'a> DeleteStickerFromSet<'a> {
Self { bot, sticker } Self { bot, sticker }
} }
/// File identifier of the sticker.
pub fn sticker<T>(mut self, val: T) -> Self pub fn sticker<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,

View file

@ -8,7 +8,11 @@ use crate::{
}; };
/// 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 getUpdates. Returns True on success. Requires no parameters. /// to [Bot::get_updates].
///
/// [The official docs](https://core.telegram.org/bots/api#deletewebhook).
///
/// [Bot::get_updates]: crate::Bot::get_updates
#[serde_with_macros::skip_serializing_none] #[serde_with_macros::skip_serializing_none]
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct DeleteWebhook<'a> { pub struct DeleteWebhook<'a> {

View file

@ -8,23 +8,22 @@ use crate::{
}; };
/// Use this method to edit captions of messages. On success, if edited message /// Use this method to edit captions of messages. On success, if edited message
/// is sent by the bot, the edited Message is returned, otherwise True is /// is sent by the bot, the edited [`Message`] is returned, otherwise [`True`]
/// returned. /// is returned.
///
/// [The official docs](https://core.telegram.org/bots/api#editmessagecaption).
///
/// [`Message`]: crate::types::Message
/// [`True`]: crate::types::True
#[serde_with_macros::skip_serializing_none] #[serde_with_macros::skip_serializing_none]
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct EditMessageCaption<'a> { pub struct EditMessageCaption<'a> {
#[serde(skip_serializing)] #[serde(skip_serializing)]
bot: &'a Bot, bot: &'a Bot,
#[serde(flatten)] #[serde(flatten)]
chat_or_inline_message: ChatOrInlineMessage, chat_or_inline_message: ChatOrInlineMessage,
/// New caption of the message
caption: Option<String>, caption: Option<String>,
/// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
/// fixed-width text or inline URLs in the media caption.
parse_mode: Option<ParseMode>, parse_mode: Option<ParseMode>,
/// A JSON-serialized object for an inline keyboard.
reply_markup: Option<InlineKeyboardMarkup>, reply_markup: Option<InlineKeyboardMarkup>,
} }
@ -62,6 +61,7 @@ impl<'a> EditMessageCaption<'a> {
self self
} }
/// New caption of the message.
pub fn caption<T>(mut self, val: T) -> Self pub fn caption<T>(mut self, val: T) -> Self
where where
T: Into<String>, T: Into<String>,
@ -70,11 +70,20 @@ impl<'a> EditMessageCaption<'a> {
self self
} }
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub fn parse_mode(mut self, val: ParseMode) -> Self { pub fn parse_mode(mut self, val: ParseMode) -> Self {
self.parse_mode = Some(val); self.parse_mode = Some(val);
self self
} }
/// A JSON-serialized object for an [inline keyboard].
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self { pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val); self.reply_markup = Some(val);
self self