From 81167ff44d72314fa1221e0ebdcc0291696a1de2 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Tue, 21 Jan 2020 01:03:03 +0600 Subject: [PATCH] Fix the docs of several requests --- src/requests/all/add_sticker_to_set.rs | 30 +++++---- src/requests/all/answer_callback_query.rs | 47 +++++++------ src/requests/all/answer_inline_query.rs | 66 +++++++++++-------- src/requests/all/answer_pre_checkout_query.rs | 33 +++++----- src/requests/all/answer_shipping_query.rs | 29 ++++---- src/requests/all/create_new_sticker_set.rs | 41 ++++++------ src/requests/all/delete_chat_photo.rs | 9 +-- src/requests/all/delete_chat_sticker_set.rs | 15 +++-- src/requests/all/delete_message.rs | 31 +++++---- src/requests/all/delete_sticker_from_set.rs | 8 +-- src/requests/all/delete_webhook.rs | 6 +- src/requests/all/edit_message_caption.rs | 25 ++++--- 12 files changed, 194 insertions(+), 146 deletions(-) diff --git a/src/requests/all/add_sticker_to_set.rs b/src/requests/all/add_sticker_to_set.rs index 7dc37e50..9463afd3 100644 --- a/src/requests/all/add_sticker_to_set.rs +++ b/src/requests/all/add_sticker_to_set.rs @@ -7,27 +7,16 @@ use crate::{ use crate::requests::{Request, ResponseResult}; -/// Use this method to add a new sticker to a set created by the bot. Returns -/// True on success. +/// Use this method to add a new sticker to a set created by the bot. +/// +/// [The official docs](https://core.telegram.org/bots/api#addstickertoset). #[derive(Debug, Clone)] pub struct AddStickerToSet<'a> { bot: &'a Bot, - - /// User identifier of sticker set owner user_id: i32, - /// Sticker set name 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, - /// One or more emoji corresponding to the sticker emojis: String, - /// A JSON-serialized object for position where the mask should be placed - /// on faces mask_position: Option, } @@ -79,11 +68,13 @@ impl<'a> AddStickerToSet<'a> { } } + /// User identifier of sticker set owner. pub fn user_id(mut self, val: i32) -> Self { self.user_id = val; self } + /// Sticker set name. pub fn name(mut self, val: T) -> Self where T: Into, @@ -92,11 +83,20 @@ impl<'a> AddStickerToSet<'a> { 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 { self.png_sticker = val; self } + /// One or more emoji corresponding to the sticker. pub fn emojis(mut self, val: T) -> Self where T: Into, @@ -105,6 +105,8 @@ impl<'a> AddStickerToSet<'a> { self } + /// A JSON-serialized object for position where the mask should be placed on + /// faces. pub fn mask_position(mut self, val: MaskPosition) -> Self { self.mask_position = Some(val); self diff --git a/src/requests/all/answer_callback_query.rs b/src/requests/all/answer_callback_query.rs index 77b1b7f5..721c30f3 100644 --- a/src/requests/all/answer_callback_query.rs +++ b/src/requests/all/answer_callback_query.rs @@ -7,36 +7,22 @@ use crate::{ Bot, }; -/// 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 -/// top of the chat screen or as an alert. On success, True is -/// 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 -/// @Botfather and accept the terms. Otherwise, you may use links like -/// t.me/your_bot?start=XXXX that open your bot with a parameter. +/// 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 top of the chat screen or as an alert. +/// +/// [The official docs](https://core.telegram.org/bots/api#answercallbackquery). +/// +/// [inline keyboards]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating #[serde_with_macros::skip_serializing_none] #[derive(Debug, Clone, Serialize)] pub struct AnswerCallbackQuery<'a> { #[serde(skip_serializing)] bot: &'a Bot, - - /// Unique identifier for the query to be answered callback_query_id: String, - /// Text of the notification. If not specified, nothing will be shown to - /// the user, 0-200 characters text: Option, - /// 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, - /// 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, - /// 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, } @@ -71,6 +57,7 @@ impl<'a> AnswerCallbackQuery<'a> { } } + /// Unique identifier for the query to be answered. pub fn callback_query_id(mut self, val: T) -> Self where T: Into, @@ -79,6 +66,8 @@ impl<'a> AnswerCallbackQuery<'a> { self } + /// Text of the notification. If not specified, nothing will be shown to the + /// user, 0-200 characters. pub fn text(mut self, val: T) -> Self where T: Into, @@ -87,11 +76,24 @@ impl<'a> AnswerCallbackQuery<'a> { 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 { self.show_alert = Some(val); 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(mut self, val: T) -> Self where T: Into, @@ -100,6 +102,9 @@ impl<'a> AnswerCallbackQuery<'a> { 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 { self.cache_time = Some(val); self diff --git a/src/requests/all/answer_inline_query.rs b/src/requests/all/answer_inline_query.rs index 5cd7bfdb..8bceafc2 100644 --- a/src/requests/all/answer_inline_query.rs +++ b/src/requests/all/answer_inline_query.rs @@ -7,45 +7,22 @@ use crate::{ Bot, }; -/// Use this method to send answers to an inline query. On success, True is -/// returned.No more than 50 results per query are allowed. +/// Use this method to send answers to an inline query. +/// +/// 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] #[derive(Debug, Clone, Serialize)] pub struct AnswerInlineQuery<'a> { #[serde(skip_serializing)] bot: &'a Bot, - - /// Unique identifier for the answered query inline_query_id: String, - /// A JSON-serialized array of results for the inline query results: Vec, - /// 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, - /// 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, - /// 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 don‘t support pagination. Offset length can’t - /// exceed 64 bytes. next_offset: Option, - /// 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, - /// 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, } @@ -88,6 +65,7 @@ impl<'a> AnswerInlineQuery<'a> { } } + /// Unique identifier for the answered query/ pub fn inline_query_id(mut self, val: T) -> Self where T: Into, @@ -96,6 +74,7 @@ impl<'a> AnswerInlineQuery<'a> { self } + /// A JSON-serialized array of results for the inline query. pub fn results(mut self, val: T) -> Self where T: Into>, @@ -104,17 +83,26 @@ impl<'a> AnswerInlineQuery<'a> { 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 { self.cache_time = Some(val); 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)] pub fn is_personal(mut self, val: bool) -> Self { self.is_personal = Some(val); 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 don‘t support pagination. Offset length can’t + /// exceed 64 bytes. pub fn next_offset(mut self, val: T) -> Self where T: Into, @@ -123,6 +111,12 @@ impl<'a> AnswerInlineQuery<'a> { 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(mut self, val: T) -> Self where T: Into, @@ -131,6 +125,22 @@ impl<'a> AnswerInlineQuery<'a> { 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(mut self, val: T) -> Self where T: Into, diff --git a/src/requests/all/answer_pre_checkout_query.rs b/src/requests/all/answer_pre_checkout_query.rs index d1760ebb..eebcbc6a 100644 --- a/src/requests/all/answer_pre_checkout_query.rs +++ b/src/requests/all/answer_pre_checkout_query.rs @@ -8,28 +8,21 @@ use crate::{ }; /// 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 -/// pre_checkout_query. Use this method to respond to such pre-checkout queries. -/// On success, True is returned. Note: The Bot API must receive an answer -/// within 10 seconds after the pre-checkout query was sent. +/// 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. Note: The Bot API must receive an answer within 10 seconds after +/// 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] #[derive(Debug, Clone, Serialize)] pub struct AnswerPreCheckoutQuery<'a> { #[serde(skip_serializing)] bot: &'a Bot, - - /// Unique identifier for the query to be answered 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, - /// 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, } @@ -66,6 +59,7 @@ impl<'a> AnswerPreCheckoutQuery<'a> { } } + /// Unique identifier for the query to be answered. pub fn pre_checkout_query_id(mut self, val: T) -> Self where T: Into, @@ -74,11 +68,20 @@ impl<'a> AnswerPreCheckoutQuery<'a> { 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 { self.ok = val; 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(mut self, val: T) -> Self where T: Into, diff --git a/src/requests/all/answer_shipping_query.rs b/src/requests/all/answer_shipping_query.rs index efe55b4d..0991dbbb 100644 --- a/src/requests/all/answer_shipping_query.rs +++ b/src/requests/all/answer_shipping_query.rs @@ -8,28 +8,21 @@ use crate::{ }; /// 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 -/// 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] #[derive(Debug, Clone, Serialize)] pub struct AnswerShippingQuery<'a> { #[serde(skip_serializing)] bot: &'a Bot, - - /// Unique identifier for the query to be answered 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, - /// Required if ok is True. A JSON-serialized array of available shipping - /// options. shipping_options: Option>, - /// 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, } @@ -63,6 +56,7 @@ impl<'a> AnswerShippingQuery<'a> { } } + /// Unique identifier for the query to be answered. pub fn shipping_query_id(mut self, val: T) -> Self where T: Into, @@ -71,11 +65,16 @@ impl<'a> AnswerShippingQuery<'a> { 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 { self.ok = val; self } + /// Required if ok is `true`. A JSON-serialized array of available shipping + /// options. pub fn shipping_options(mut self, val: T) -> Self where T: Into>, @@ -84,6 +83,10 @@ impl<'a> AnswerShippingQuery<'a> { 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(mut self, val: T) -> Self where T: Into, diff --git a/src/requests/all/create_new_sticker_set.rs b/src/requests/all/create_new_sticker_set.rs index 08bd82af..99c8004b 100644 --- a/src/requests/all/create_new_sticker_set.rs +++ b/src/requests/all/create_new_sticker_set.rs @@ -6,34 +6,18 @@ use crate::{ }; /// 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)] pub struct CreateNewStickerSet<'a> { bot: &'a Bot, - - /// User identifier of created sticker set owner 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_”. is case insensitive. - /// 1-64 characters. name: String, - /// Sticker set title, 1-64 characters 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, - /// One or more emoji corresponding to the sticker emojis: String, - /// Pass True, if a set of mask stickers should be created contains_masks: Option, - /// A JSON-serialized object for position where the mask should be placed - /// on faces mask_position: Option, } @@ -93,11 +77,17 @@ impl<'a> CreateNewStickerSet<'a> { } } + /// User identifier of created sticker set owner. pub fn user_id(mut self, val: i32) -> Self { self.user_id = val; 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_`. `` is case insensitive. 1-64 + /// characters. pub fn name(mut self, val: T) -> Self where T: Into, @@ -106,6 +96,7 @@ impl<'a> CreateNewStickerSet<'a> { self } + /// Sticker set title, 1-64 characters. pub fn title(mut self, val: T) -> Self where T: Into, @@ -114,11 +105,20 @@ impl<'a> CreateNewStickerSet<'a> { 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 { self.png_sticker = val; self } + /// One or more emoji corresponding to the sticker. pub fn emojis(mut self, val: T) -> Self where T: Into, @@ -127,11 +127,14 @@ impl<'a> CreateNewStickerSet<'a> { self } + /// Pass `true`, if a set of mask stickers should be created. pub fn contains_masks(mut self, val: bool) -> Self { self.contains_masks = Some(val); self } + /// A JSON-serialized object for position where the mask should be placed on + /// faces. pub fn mask_position(mut self, val: MaskPosition) -> Self { self.mask_position = Some(val); self diff --git a/src/requests/all/delete_chat_photo.rs b/src/requests/all/delete_chat_photo.rs index 0d2fe447..9f0d9fa7 100644 --- a/src/requests/all/delete_chat_photo.rs +++ b/src/requests/all/delete_chat_photo.rs @@ -9,15 +9,14 @@ use crate::{ /// 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 -/// 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] #[derive(Debug, Clone, Serialize)] pub struct DeleteChatPhoto<'a> { #[serde(skip_serializing)] bot: &'a Bot, - - /// Unique identifier for the target chat or username of the target channel - /// (in the format @channelusername) chat_id: ChatId, } @@ -45,6 +44,8 @@ impl<'a> DeleteChatPhoto<'a> { Self { bot, chat_id } } + /// Unique identifier for the target chat or username of the target channel + /// (in the format `@channelusername`). pub fn chat_id(mut self, val: T) -> Self where T: Into, diff --git a/src/requests/all/delete_chat_sticker_set.rs b/src/requests/all/delete_chat_sticker_set.rs index 1e26eb1f..a207dbfc 100644 --- a/src/requests/all/delete_chat_sticker_set.rs +++ b/src/requests/all/delete_chat_sticker_set.rs @@ -9,17 +9,18 @@ use crate::{ /// 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 -/// appropriate admin rights. Use the field can_set_sticker_set optionally -/// returned in getChat requests to check if the bot can use this method. -/// Returns True on success. +/// appropriate admin rights. Use the field `can_set_sticker_set` optionally +/// returned in [`Bot::get_chat`] requests to check if the bot can use this +/// method. +/// +/// [The official docs](https://core.telegram.org/bots/api#deletechatstickerset). +/// +/// [`Bot::get_chat`]: crate::Bot::get_chat #[serde_with_macros::skip_serializing_none] #[derive(Debug, Clone, Serialize)] pub struct DeleteChatStickerSet<'a> { #[serde(skip_serializing)] bot: &'a Bot, - - /// Unique identifier for the target chat or username of the target - /// supergroup (in the format @supergroupusername) chat_id: ChatId, } @@ -47,6 +48,8 @@ impl<'a> DeleteChatStickerSet<'a> { Self { bot, chat_id } } + /// Unique identifier for the target chat or username of the target + /// supergroup (in the format `@supergroupusername`). pub fn chat_id(mut self, val: T) -> Self where T: Into, diff --git a/src/requests/all/delete_message.rs b/src/requests/all/delete_message.rs index 97625805..322d0c7a 100644 --- a/src/requests/all/delete_message.rs +++ b/src/requests/all/delete_message.rs @@ -7,25 +7,27 @@ use crate::{ Bot, }; -/// Use this method to delete a message, including service messages, with the -/// 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, -/// groups, and supergroups.- Bots can delete incoming messages in private -/// chats.- Bots granted can_post_messages permissions can delete outgoing -/// messages 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.Returns True on -/// success. +/// Use this method to delete a message, including service messages. +/// +/// The limitations are: +/// - A message can only be deleted if it was sent less than 48 hours ago. +/// - Bots can delete outgoing messages in private chats, groups, and +/// supergroups. +/// - Bots can delete incoming messages in private chats. +/// - Bots granted can_post_messages permissions can delete outgoing messages +/// 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] #[derive(Debug, Clone, Serialize)] pub struct DeleteMessage<'a> { #[serde(skip_serializing)] bot: &'a Bot, - - /// Unique identifier for the target chat or username of the target channel - /// (in the format @channelusername) chat_id: ChatId, - /// Identifier of the message to delete 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(mut self, val: T) -> Self where T: Into, @@ -65,6 +69,7 @@ impl<'a> DeleteMessage<'a> { self } + /// Identifier of the message to delete. pub fn message_id(mut self, val: i32) -> Self { self.message_id = val; self diff --git a/src/requests/all/delete_sticker_from_set.rs b/src/requests/all/delete_sticker_from_set.rs index 0b8eb12b..fe092107 100644 --- a/src/requests/all/delete_sticker_from_set.rs +++ b/src/requests/all/delete_sticker_from_set.rs @@ -7,15 +7,14 @@ use crate::{ Bot, }; -/// Use this method to delete a sticker from a set created by the bot. Returns -/// True on success. +/// Use this method to delete a sticker from a set created by the bot. +/// +/// [The official docs](https://core.telegram.org/bots/api#deletestickerfromset). #[serde_with_macros::skip_serializing_none] #[derive(Debug, Clone, Serialize)] pub struct DeleteStickerFromSet<'a> { #[serde(skip_serializing)] bot: &'a Bot, - - /// File identifier of the sticker sticker: String, } @@ -43,6 +42,7 @@ impl<'a> DeleteStickerFromSet<'a> { Self { bot, sticker } } + /// File identifier of the sticker. pub fn sticker(mut self, val: T) -> Self where T: Into, diff --git a/src/requests/all/delete_webhook.rs b/src/requests/all/delete_webhook.rs index e0aebc83..71c9a2c9 100644 --- a/src/requests/all/delete_webhook.rs +++ b/src/requests/all/delete_webhook.rs @@ -8,7 +8,11 @@ use crate::{ }; /// 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] #[derive(Debug, Clone, Serialize)] pub struct DeleteWebhook<'a> { diff --git a/src/requests/all/edit_message_caption.rs b/src/requests/all/edit_message_caption.rs index 7e0b6328..17c8b927 100644 --- a/src/requests/all/edit_message_caption.rs +++ b/src/requests/all/edit_message_caption.rs @@ -8,23 +8,22 @@ use crate::{ }; /// 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 -/// returned. +/// is sent by the bot, the edited [`Message`] is returned, otherwise [`True`] +/// 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] #[derive(Debug, Clone, Serialize)] pub struct EditMessageCaption<'a> { #[serde(skip_serializing)] bot: &'a Bot, - #[serde(flatten)] chat_or_inline_message: ChatOrInlineMessage, - - /// New caption of the message caption: Option, - /// 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, - /// A JSON-serialized object for an inline keyboard. reply_markup: Option, } @@ -62,6 +61,7 @@ impl<'a> EditMessageCaption<'a> { self } + /// New caption of the message. pub fn caption(mut self, val: T) -> Self where T: Into, @@ -70,11 +70,20 @@ impl<'a> EditMessageCaption<'a> { 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 { self.parse_mode = Some(val); 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 { self.reply_markup = Some(val); self