Add the ReplyParameters struct

This commit is contained in:
Сырцев Вадим Игоревич 2024-07-18 18:37:34 +03:00 committed by Andrey Brusnik
parent 8f9b6d13ca
commit 7680d7e978
No known key found for this signature in database
GPG key ID: D33232F28CFF442C
25 changed files with 185 additions and 273 deletions

View file

@ -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",

View file

@ -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

View file

@ -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<MessageId> {

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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,
}
}
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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<E: serde::de::Error>(
@ -446,16 +446,6 @@ pub(crate) mod option_msg_id_as_int {
}
}
pub(crate) fn serialize_reply_to_message_id<S>(
this: &Option<MessageId>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
this.map(|MessageId(id)| id).serialize(serializer)
}
pub(crate) mod serde_rgb {
use serde::{de::Visitor, Deserializer, Serializer};

View file

@ -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);

View file

@ -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<Recipient>,
/// 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<bool>,
/// 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<String>,
}
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
}
}

View file

@ -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(())
}),