mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Add the quote field of typeTextQuote
to the Message
struct
This commit is contained in:
parent
7680d7e978
commit
298df305f0
4 changed files with 43 additions and 4 deletions
|
@ -114,6 +114,7 @@ pub use story::*;
|
||||||
pub use successful_payment::*;
|
pub use successful_payment::*;
|
||||||
pub use switch_inline_query_chosen_chat::*;
|
pub use switch_inline_query_chosen_chat::*;
|
||||||
pub use target_message::*;
|
pub use target_message::*;
|
||||||
|
pub use text_quote::*;
|
||||||
pub use thread_id::*;
|
pub use thread_id::*;
|
||||||
pub use unit_false::*;
|
pub use unit_false::*;
|
||||||
pub use unit_true::*;
|
pub use unit_true::*;
|
||||||
|
@ -221,6 +222,7 @@ mod story;
|
||||||
mod successful_payment;
|
mod successful_payment;
|
||||||
mod switch_inline_query_chosen_chat;
|
mod switch_inline_query_chosen_chat;
|
||||||
mod target_message;
|
mod target_message;
|
||||||
|
mod text_quote;
|
||||||
mod thread_id;
|
mod thread_id;
|
||||||
mod unit_false;
|
mod unit_false;
|
||||||
mod unit_true;
|
mod unit_true;
|
||||||
|
|
|
@ -10,9 +10,9 @@ use crate::types::{
|
||||||
GeneralForumTopicHidden, GeneralForumTopicUnhidden, InlineKeyboardMarkup, Invoice, Location,
|
GeneralForumTopicHidden, GeneralForumTopicUnhidden, InlineKeyboardMarkup, Invoice, Location,
|
||||||
MaybeInaccessibleMessage, MessageAutoDeleteTimerChanged, MessageEntity, MessageEntityRef,
|
MaybeInaccessibleMessage, MessageAutoDeleteTimerChanged, MessageEntity, MessageEntityRef,
|
||||||
MessageId, MessageOrigin, PassportData, PhotoSize, Poll, ProximityAlertTriggered, Sticker,
|
MessageId, MessageOrigin, PassportData, PhotoSize, Poll, ProximityAlertTriggered, Sticker,
|
||||||
Story, SuccessfulPayment, ThreadId, True, User, UsersShared, Venue, Video, VideoChatEnded,
|
Story, SuccessfulPayment, TextQuote, ThreadId, True, User, UsersShared, Venue, Video,
|
||||||
VideoChatParticipantsInvited, VideoChatScheduled, VideoChatStarted, VideoNote, Voice,
|
VideoChatEnded, VideoChatParticipantsInvited, VideoChatScheduled, VideoChatStarted, VideoNote,
|
||||||
WebAppData, WriteAccessAllowed,
|
Voice, WebAppData, WriteAccessAllowed,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This object represents a message.
|
/// This object represents a message.
|
||||||
|
@ -110,6 +110,10 @@ pub struct MessageCommon {
|
||||||
/// itself is a reply.
|
/// itself is a reply.
|
||||||
pub reply_to_message: Option<Box<Message>>,
|
pub reply_to_message: Option<Box<Message>>,
|
||||||
|
|
||||||
|
/// For replies that quote part of the original message, the quoted part of
|
||||||
|
/// the message
|
||||||
|
pub quote: Option<TextQuote>,
|
||||||
|
|
||||||
/// Date the message was last edited in Unix time.
|
/// Date the message was last edited in Unix time.
|
||||||
#[serde(default, with = "crate::types::serde_opt_date_from_unix_timestamp")]
|
#[serde(default, with = "crate::types::serde_opt_date_from_unix_timestamp")]
|
||||||
pub edit_date: Option<DateTime<Utc>>,
|
pub edit_date: Option<DateTime<Utc>>,
|
||||||
|
@ -637,7 +641,7 @@ mod getters {
|
||||||
MessageLeftChatMember, MessageNewChatMembers, MessageNewChatPhoto, MessageNewChatTitle,
|
MessageLeftChatMember, MessageNewChatMembers, MessageNewChatPhoto, MessageNewChatTitle,
|
||||||
MessageOrigin, MessagePassportData, MessagePinned, MessageProximityAlertTriggered,
|
MessageOrigin, MessagePassportData, MessagePinned, MessageProximityAlertTriggered,
|
||||||
MessageSuccessfulPayment, MessageSupergroupChatCreated, MessageUsersShared,
|
MessageSuccessfulPayment, MessageSupergroupChatCreated, MessageUsersShared,
|
||||||
MessageVideoChatParticipantsInvited, PhotoSize, User,
|
MessageVideoChatParticipantsInvited, PhotoSize, TextQuote, User,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -686,6 +690,14 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn quote(&self) -> Option<&TextQuote> {
|
||||||
|
match &self.kind {
|
||||||
|
Common(MessageCommon { quote, .. }) => quote.as_ref(),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn forward_date(&self) -> Option<DateTime<Utc>> {
|
pub fn forward_date(&self) -> Option<DateTime<Utc>> {
|
||||||
self.forward_origin().map(|f| f.date())
|
self.forward_origin().map(|f| f.date())
|
||||||
|
|
24
crates/teloxide-core/src/types/text_quote.rs
Normal file
24
crates/teloxide-core/src/types/text_quote.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::types::MessageEntity;
|
||||||
|
|
||||||
|
/// This object contains information about the quoted part of a message that is
|
||||||
|
/// replied to by the given message.
|
||||||
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub struct TextQuote {
|
||||||
|
/// Text of the quoted part of a message that is replied to by the given
|
||||||
|
/// message
|
||||||
|
pub text: String,
|
||||||
|
/// Special entities that appear in the quote. Currently, only _bold_,
|
||||||
|
/// _italic_, _underline_, _strikethrough_, _spoiler_, and
|
||||||
|
/// _custom_emoji_ entities are kept in quotes.
|
||||||
|
#[serde(default)]
|
||||||
|
pub entities: Vec<MessageEntity>,
|
||||||
|
/// Approximate quote position in the original message in UTF-16 code units
|
||||||
|
/// as specified by the sender
|
||||||
|
pub position: u32,
|
||||||
|
/// True, if the quote was chosen manually by the message sender. Otherwise,
|
||||||
|
/// the quote was added automatically by the server.
|
||||||
|
#[serde(default)]
|
||||||
|
pub is_manual: bool,
|
||||||
|
}
|
|
@ -456,6 +456,7 @@ mod test {
|
||||||
}),
|
}),
|
||||||
reply_to_message: None,
|
reply_to_message: None,
|
||||||
forward_origin: None,
|
forward_origin: None,
|
||||||
|
quote: None,
|
||||||
edit_date: None,
|
edit_date: None,
|
||||||
media_kind: MediaKind::Text(MediaText {
|
media_kind: MediaKind::Text(MediaText {
|
||||||
text: String::from("hello there"),
|
text: String::from("hello there"),
|
||||||
|
|
Loading…
Reference in a new issue