Add reply_to_story field to MessageCommon

also add `reply_to_story` getter to `Message` struct and `filter_reply_to_story` filter to `MessageFilterExt`
This commit is contained in:
Andrey Brusnik 2024-07-20 18:06:45 +04:00
parent 4905758a78
commit 7e4d29cf15
No known key found for this signature in database
GPG key ID: D33232F28CFF442C
3 changed files with 14 additions and 1 deletions

View file

@ -128,6 +128,9 @@ pub struct MessageCommon {
/// the message /// the message
pub quote: Option<TextQuote>, pub quote: Option<TextQuote>,
/// For replies to a story, the original story
pub reply_to_story: Option<Story>,
/// If the sender of the message boosted the chat, the number of boosts /// If the sender of the message boosted the chat, the number of boosts
/// added by the user /// added by the user
pub sender_boost_count: Option<u16>, pub sender_boost_count: Option<u16>,
@ -704,7 +707,7 @@ mod getters {
MessageInvoice, MessageLeftChatMember, MessageNewChatMembers, MessageNewChatPhoto, MessageInvoice, MessageLeftChatMember, MessageNewChatMembers, MessageNewChatPhoto,
MessageNewChatTitle, MessageOrigin, MessagePassportData, MessagePinned, MessageNewChatTitle, MessageOrigin, MessagePassportData, MessagePinned,
MessageProximityAlertTriggered, MessageSuccessfulPayment, MessageSupergroupChatCreated, MessageProximityAlertTriggered, MessageSuccessfulPayment, MessageSupergroupChatCreated,
MessageUsersShared, MessageVideoChatParticipantsInvited, PhotoSize, TextQuote, User, MessageUsersShared, MessageVideoChatParticipantsInvited, PhotoSize, Story, TextQuote, User,
}; };
use super::{ use super::{
@ -758,6 +761,14 @@ mod getters {
} }
} }
#[must_use]
pub fn reply_to_story(&self) -> Option<&Story> {
match &self.kind {
Common(MessageCommon { reply_to_story, .. }) => reply_to_story.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())

View file

@ -548,6 +548,7 @@ mod test {
forward_origin: None, forward_origin: None,
external_reply: None, external_reply: None,
quote: None, quote: None,
reply_to_story: None,
sender_boost_count: None, sender_boost_count: None,
edit_date: None, edit_date: None,
media_kind: MediaKind::Text(MediaText { media_kind: MediaKind::Text(MediaText {

View file

@ -96,6 +96,7 @@ define_message_ext! {
(filter_migration_to, Message::migrate_to_chat_id), (filter_migration_to, Message::migrate_to_chat_id),
(filter_reply_to_message, Message::reply_to_message), (filter_reply_to_message, Message::reply_to_message),
(filter_forward_origin, Message::forward_origin), (filter_forward_origin, Message::forward_origin),
(filter_reply_to_story, Message::reply_to_story),
// Rest variants of a MessageKind // Rest variants of a MessageKind
(filter_new_chat_members, Message::new_chat_members), (filter_new_chat_members, Message::new_chat_members),
(filter_left_chat_member, Message::left_chat_member), (filter_left_chat_member, Message::left_chat_member),