diff --git a/crates/teloxide-core/schema.ron b/crates/teloxide-core/schema.ron index e4206f77..7d6ff142 100644 --- a/crates/teloxide-core/schema.ron +++ b/crates/teloxide-core/schema.ron @@ -271,14 +271,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -445,14 +440,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -471,9 +461,8 @@ Schema( names: ("copyMessages", "CopyMessages", "copy_messages"), return_ty: ArrayOf(RawTy("MessageId")), doc: Doc( - md: "Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz [poll] can be copied only if the value of the field _correct\\_option\\_id_ is known to the bot. The method is analogous to the method [forwardMessages], but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of [MessageId] of the sent messages is returned.", + md: "Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field _correct\\_option\\_id_ is known to the bot. The method is analogous to the method [forwardMessages], but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of [MessageId] of the sent messages is returned.", md_links: { - "poll": "https://core.telegram.org/bots/api#poll", "forwardMessages": "https://core.telegram.org/bots/api#forwardmessages", "MessageId": "https://core.telegram.org/bots/api#messageid" }, @@ -586,14 +575,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -694,14 +678,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -789,14 +768,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -907,14 +881,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -1018,14 +987,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -1104,14 +1068,9 @@ Schema( ) ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -1189,14 +1148,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -1251,14 +1205,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), ], ), @@ -1329,14 +1278,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -1607,14 +1551,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -1686,14 +1625,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -1805,14 +1739,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -1866,14 +1795,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -3697,14 +3621,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -4168,14 +4087,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", @@ -4419,14 +4333,9 @@ Schema( descr: Doc(md: "Protects the contents of sent messages from forwarding and saving"), ), Param( - name: "reply_to_message_id", - ty: Option(RawTy("MessageId")), - descr: Doc(md: "If the message is a reply, ID of the original message") - ), - Param( - name: "allow_sending_without_reply", - ty: Option(bool), - descr: Doc(md: "Pass _True_, if the message should be sent even if the specified replied-to message is not found") + name: "reply_parameters", + ty: Option(RawTy("ReplyParameters")), + descr: Doc(md: "Description of the message to reply to"), ), Param( name: "reply_markup", diff --git a/crates/teloxide-core/src/payloads/copy_message.rs b/crates/teloxide-core/src/payloads/copy_message.rs index 479cbae4..daa67928 100644 --- a/crates/teloxide-core/src/payloads/copy_message.rs +++ b/crates/teloxide-core/src/payloads/copy_message.rs @@ -2,7 +2,9 @@ use serde::Serialize; -use crate::types::{MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId}; +use crate::types::{ + MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId, +}; impl_payload! { /// Use this method to copy messages of any kind. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the [`MessageId`] of the sent message on success. @@ -36,11 +38,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/copy_messages.rs b/crates/teloxide-core/src/payloads/copy_messages.rs index 033a5c64..90a4cd90 100644 --- a/crates/teloxide-core/src/payloads/copy_messages.rs +++ b/crates/teloxide-core/src/payloads/copy_messages.rs @@ -5,10 +5,9 @@ use serde::Serialize; use crate::types::{MessageId, Recipient, ThreadId}; impl_payload! { - /// Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz [`Poll`] can be copied only if the value of the field _correct\_option\_id_ is known to the bot. The method is analogous to the method [`ForwardMessages`], but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of [`MessageId`] of the sent messages is returned. + /// Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field _correct\_option\_id_ is known to the bot. The method is analogous to the method [`ForwardMessages`], but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of [`MessageId`] of the sent messages is returned. /// /// [`MessageId`]: crate::types::MessageId - /// [`Poll`]: crate::payloads::Poll /// [`ForwardMessages`]: crate::payloads::ForwardMessages #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] pub CopyMessages (CopyMessagesSetters) => Vec { diff --git a/crates/teloxide-core/src/payloads/send_animation.rs b/crates/teloxide-core/src/payloads/send_animation.rs index 500a66a5..ba2348ee 100644 --- a/crates/teloxide-core/src/payloads/send_animation.rs +++ b/crates/teloxide-core/src/payloads/send_animation.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, + InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId, }; impl_payload! { @@ -50,11 +50,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_audio.rs b/crates/teloxide-core/src/payloads/send_audio.rs index fcb12f4d..2c579ec8 100644 --- a/crates/teloxide-core/src/payloads/send_audio.rs +++ b/crates/teloxide-core/src/payloads/send_audio.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, + InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId, }; impl_payload! { @@ -51,11 +51,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_contact.rs b/crates/teloxide-core/src/payloads/send_contact.rs index 7179cbcc..b350b1b5 100644 --- a/crates/teloxide-core/src/payloads/send_contact.rs +++ b/crates/teloxide-core/src/payloads/send_contact.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Message, MessageId, Recipient, ReplyMarkup, ThreadId}; +use crate::types::{Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId}; impl_payload! { /// Use this method to send phone contacts. On success, the sent [`Message`] is returned. @@ -33,11 +33,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_dice.rs b/crates/teloxide-core/src/payloads/send_dice.rs index 2a00cbd8..2444c39b 100644 --- a/crates/teloxide-core/src/payloads/send_dice.rs +++ b/crates/teloxide-core/src/payloads/send_dice.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{DiceEmoji, Message, MessageId, Recipient, ReplyMarkup, ThreadId}; +use crate::types::{DiceEmoji, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId}; impl_payload! { /// Use this method to send an animated emoji that will display a random value. On success, the sent [`Message`] is returned. @@ -25,11 +25,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_document.rs b/crates/teloxide-core/src/payloads/send_document.rs index cfe41cc4..7f570058 100644 --- a/crates/teloxide-core/src/payloads/send_document.rs +++ b/crates/teloxide-core/src/payloads/send_document.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, + InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId, }; impl_payload! { @@ -44,11 +44,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_game.rs b/crates/teloxide-core/src/payloads/send_game.rs index bb2b02c2..0b355e1f 100644 --- a/crates/teloxide-core/src/payloads/send_game.rs +++ b/crates/teloxide-core/src/payloads/send_game.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{ChatId, Message, MessageId, ReplyMarkup, ThreadId}; +use crate::types::{ChatId, Message, ReplyMarkup, ReplyParameters, ThreadId}; impl_payload! { /// Use this method to send a game. On success, the sent [`Message`] is returned. @@ -25,11 +25,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// A JSON-serialized object for an [inline keyboard]. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_invoice.rs b/crates/teloxide-core/src/payloads/send_invoice.rs index 278c7dcf..3c199157 100644 --- a/crates/teloxide-core/src/payloads/send_invoice.rs +++ b/crates/teloxide-core/src/payloads/send_invoice.rs @@ -3,7 +3,9 @@ use serde::Serialize; use url::Url; -use crate::types::{InlineKeyboardMarkup, LabeledPrice, Message, MessageId, Recipient, ThreadId}; +use crate::types::{ + InlineKeyboardMarkup, LabeledPrice, Message, Recipient, ReplyParameters, ThreadId, +}; impl_payload! { /// Use this method to send invoices. On success, the sent [`Message`] is returned. @@ -70,11 +72,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// A JSON-serialized object for an [inline keyboard]. If empty, one 'Pay `total price`' button will be shown. If not empty, the first button must be a Pay button. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_location.rs b/crates/teloxide-core/src/payloads/send_location.rs index 5d61cbe1..f1e0f736 100644 --- a/crates/teloxide-core/src/payloads/send_location.rs +++ b/crates/teloxide-core/src/payloads/send_location.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Message, MessageId, Recipient, ReplyMarkup, ThreadId}; +use crate::types::{Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId}; impl_payload! { /// Use this method to send point on the map. On success, the sent [`Message`] is returned. @@ -37,11 +37,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_media_group.rs b/crates/teloxide-core/src/payloads/send_media_group.rs index f5300c84..0098ead4 100644 --- a/crates/teloxide-core/src/payloads/send_media_group.rs +++ b/crates/teloxide-core/src/payloads/send_media_group.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{InputMedia, Message, MessageId, Recipient, ThreadId}; +use crate::types::{InputMedia, Message, Recipient, ReplyParameters, ThreadId}; impl_payload! { /// Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of [`Message`]s that were sent is returned. @@ -34,11 +34,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, } } } diff --git a/crates/teloxide-core/src/payloads/send_message.rs b/crates/teloxide-core/src/payloads/send_message.rs index b243aec3..129c860a 100644 --- a/crates/teloxide-core/src/payloads/send_message.rs +++ b/crates/teloxide-core/src/payloads/send_message.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, + Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId, }; impl_payload! { @@ -35,11 +35,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_photo.rs b/crates/teloxide-core/src/payloads/send_photo.rs index 0c89cc90..452b16e7 100644 --- a/crates/teloxide-core/src/payloads/send_photo.rs +++ b/crates/teloxide-core/src/payloads/send_photo.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, + InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId, }; impl_payload! { @@ -40,11 +40,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_poll.rs b/crates/teloxide-core/src/payloads/send_poll.rs index 7e521263..aaa69580 100644 --- a/crates/teloxide-core/src/payloads/send_poll.rs +++ b/crates/teloxide-core/src/payloads/send_poll.rs @@ -4,7 +4,7 @@ use chrono::{DateTime, Utc}; use serde::Serialize; use crate::types::{ - Message, MessageEntity, MessageId, ParseMode, PollType, Recipient, ReplyMarkup, ThreadId, + Message, MessageEntity, ParseMode, PollType, Recipient, ReplyMarkup, ReplyParameters, ThreadId, }; impl_payload! { @@ -54,11 +54,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_sticker.rs b/crates/teloxide-core/src/payloads/send_sticker.rs index 72dd9e2f..13678400 100644 --- a/crates/teloxide-core/src/payloads/send_sticker.rs +++ b/crates/teloxide-core/src/payloads/send_sticker.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{InputFile, Message, MessageId, Recipient, ReplyMarkup, ThreadId}; +use crate::types::{InputFile, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId}; impl_payload! { @[multipart = sticker] @@ -30,11 +30,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_venue.rs b/crates/teloxide-core/src/payloads/send_venue.rs index 59fcdcbb..3ccca409 100644 --- a/crates/teloxide-core/src/payloads/send_venue.rs +++ b/crates/teloxide-core/src/payloads/send_venue.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Message, MessageId, Recipient, ReplyMarkup, ThreadId}; +use crate::types::{Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId}; impl_payload! { /// Use this method to send information about a venue. On success, the sent [`Message`] is returned. @@ -41,11 +41,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_video.rs b/crates/teloxide-core/src/payloads/send_video.rs index 4ecfc6bf..be52eb1a 100644 --- a/crates/teloxide-core/src/payloads/send_video.rs +++ b/crates/teloxide-core/src/payloads/send_video.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, + InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId, }; impl_payload! { @@ -53,11 +53,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_video_note.rs b/crates/teloxide-core/src/payloads/send_video_note.rs index 5b7afd9a..f4387c94 100644 --- a/crates/teloxide-core/src/payloads/send_video_note.rs +++ b/crates/teloxide-core/src/payloads/send_video_note.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{InputFile, Message, MessageId, Recipient, ReplyMarkup, ThreadId}; +use crate::types::{InputFile, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId}; impl_payload! { @[multipart = video_note, thumbnail] @@ -37,11 +37,8 @@ impl_payload! { pub disable_notification: bool, /// Protects the contents of sent messages from forwarding and saving pub protect_content: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/payloads/send_voice.rs b/crates/teloxide-core/src/payloads/send_voice.rs index 5e5293ed..a7d3b139 100644 --- a/crates/teloxide-core/src/payloads/send_voice.rs +++ b/crates/teloxide-core/src/payloads/send_voice.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::types::{ - InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId, + InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId, }; impl_payload! { @@ -40,11 +40,8 @@ impl_payload! { /// /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages pub disable_notification: bool, - /// If the message is a reply, ID of the original message - #[serde(serialize_with = "crate::types::serialize_reply_to_message_id")] - pub reply_to_message_id: MessageId, - /// Pass _True_, if the message should be sent even if the specified replied-to message is not found - pub allow_sending_without_reply: bool, + /// Description of the message to reply to + pub reply_parameters: ReplyParameters, /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating diff --git a/crates/teloxide-core/src/serde_multipart/mod.rs b/crates/teloxide-core/src/serde_multipart/mod.rs index 0c2966e7..a83af2b3 100644 --- a/crates/teloxide-core/src/serde_multipart/mod.rs +++ b/crates/teloxide-core/src/serde_multipart/mod.rs @@ -173,8 +173,7 @@ mod tests { .caption_entities(entities()) .thumbnail(InputFile::read( File::open("../../media/teloxide-core-logo.png").await.unwrap(), - )) - .allow_sending_without_reply(true), + )), ) .unwrap() .await; diff --git a/crates/teloxide-core/src/types.rs b/crates/teloxide-core/src/types.rs index 591e0ca3..827fbc3e 100644 --- a/crates/teloxide-core/src/types.rs +++ b/crates/teloxide-core/src/types.rs @@ -102,6 +102,7 @@ pub use proximity_alert_triggered::*; pub use reply_keyboard_markup::*; pub use reply_keyboard_remove::*; pub use reply_markup::*; +pub use reply_parameters::*; pub use response_parameters::*; pub use sent_web_app_message::*; pub use shipping_address::*; @@ -208,6 +209,7 @@ mod proximity_alert_triggered; mod reply_keyboard_markup; mod reply_keyboard_remove; mod reply_markup; +mod reply_parameters; mod response_parameters; mod sent_web_app_message; mod shipping_address; @@ -286,8 +288,6 @@ pub use recipient::*; pub use seconds::*; pub use user_id::*; -use serde::Serialize; - /// Converts an `i64` timestamp to a `choro::DateTime`, producing serde error /// for invalid timestamps pub(crate) fn serde_timestamp( @@ -446,16 +446,6 @@ pub(crate) mod option_msg_id_as_int { } } -pub(crate) fn serialize_reply_to_message_id( - this: &Option, - serializer: S, -) -> Result -where - S: serde::Serializer, -{ - this.map(|MessageId(id)| id).serialize(serializer) -} - pub(crate) mod serde_rgb { use serde::{de::Visitor, Deserializer, Serializer}; diff --git a/crates/teloxide-core/src/types/message_id.rs b/crates/teloxide-core/src/types/message_id.rs index d0f1212b..8d2e573a 100644 --- a/crates/teloxide-core/src/types/message_id.rs +++ b/crates/teloxide-core/src/types/message_id.rs @@ -1,7 +1,18 @@ use serde::{Deserialize, Serialize}; /// A unique message identifier. -#[derive(Clone, Copy, Debug, derive_more::Display, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive( + Default, + Clone, + Copy, + Debug, + derive_more::Display, + PartialEq, + Eq, + Hash, + Serialize, + Deserialize +)] #[serde(from = "MessageIdRaw", into = "MessageIdRaw")] pub struct MessageId(pub i32); diff --git a/crates/teloxide-core/src/types/reply_parameters.rs b/crates/teloxide-core/src/types/reply_parameters.rs new file mode 100644 index 00000000..c39abfcf --- /dev/null +++ b/crates/teloxide-core/src/types/reply_parameters.rs @@ -0,0 +1,50 @@ +use serde::{Deserialize, Serialize}; + +use crate::types::{MessageId, Recipient}; + +/// Describes reply parameters for the message that is being sent. +#[serde_with::skip_serializing_none] +#[derive(Default, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct ReplyParameters { + /// Identifier of the message that will be replied to in the current chat, + /// or in the chat _chat\_id_ if it is specified + pub message_id: MessageId, + /// If the message to be replied to is from a different chat, unique + /// identifier for the chat or username of the channel (in the format + /// `@channelusername`) + pub chat_id: Option, + /// Pass _true_ if the message should be sent even if the specified message + /// to be replied to is not found; can be used only for replies in the + /// same chat and forum topic. + pub allow_sending_without_reply: Option, + /// Quoted part of the message to be replied to; 0-1024 characters after + /// entities parsing. The quote must be an exact substring of the message to + /// be replied to, including _bold_, _italic_, _underline_, _strikethrough_, + /// _spoiler_, and _custom_emoji_ entities. The message will fail to send if + /// the quote isn't found in the original message. + pub quote: Option, +} + +impl ReplyParameters { + pub fn new(message_id: MessageId) -> Self { + Self { message_id, ..Self::default() } + } + + /// Setter for the `chat_id` field + pub fn chat_id(mut self, chat_id: Recipient) -> Self { + self.chat_id = Some(chat_id); + self + } + + /// Sets the `allow_sending_without_reply_field` to _true_ + pub fn allow_sending_without_reply(mut self) -> Self { + self.allow_sending_without_reply = Some(true); + self + } + + /// Setter for the `quote` field + pub fn quote(mut self, quote: String) -> Self { + self.quote = Some(quote); + self + } +} diff --git a/crates/teloxide/examples/dispatching_features.rs b/crates/teloxide/examples/dispatching_features.rs index 1082c29f..e5739a96 100644 --- a/crates/teloxide/examples/dispatching_features.rs +++ b/crates/teloxide/examples/dispatching_features.rs @@ -3,7 +3,11 @@ use rand::Rng; -use teloxide::{prelude::*, types::Dice, utils::command::BotCommands}; +use teloxide::{ + prelude::*, + types::{Dice, ReplyParameters}, + utils::command::BotCommands, +}; #[tokio::main] async fn main() { @@ -60,7 +64,7 @@ async fn main() { // filter only messages with dices. Message::filter_dice().endpoint(|bot: Bot, msg: Message, dice: Dice| async move { bot.send_message(msg.chat.id, format!("Dice value: {}", dice.value)) - .reply_to_message_id(msg.id) + .reply_parameters(ReplyParameters::new(msg.id)) .await?; Ok(()) }),