diff --git a/crates/teloxide-core/src/types.rs b/crates/teloxide-core/src/types.rs index 26128929..2b2a926b 100644 --- a/crates/teloxide-core/src/types.rs +++ b/crates/teloxide-core/src/types.rs @@ -105,6 +105,7 @@ pub use shipping_option::*; pub use shipping_query::*; pub use sticker::*; pub use sticker_set::*; +pub use story::*; pub use successful_payment::*; pub use switch_inline_query_chosen_chat::*; pub use target_message::*; @@ -206,6 +207,7 @@ mod shipping_option; mod shipping_query; mod sticker; mod sticker_set; +mod story; mod successful_payment; mod switch_inline_query_chosen_chat; mod target_message; diff --git a/crates/teloxide-core/src/types/message.rs b/crates/teloxide-core/src/types/message.rs index b80c4bbb..da36ebf9 100644 --- a/crates/teloxide-core/src/types/message.rs +++ b/crates/teloxide-core/src/types/message.rs @@ -9,9 +9,9 @@ use crate::types::{ ForumTopicClosed, ForumTopicCreated, ForumTopicEdited, ForumTopicReopened, Game, GeneralForumTopicHidden, GeneralForumTopicUnhidden, InlineKeyboardMarkup, Invoice, Location, MessageAutoDeleteTimerChanged, MessageEntity, MessageEntityRef, MessageId, PassportData, - PhotoSize, Poll, ProximityAlertTriggered, Sticker, SuccessfulPayment, ThreadId, True, User, - UserShared, Venue, Video, VideoChatEnded, VideoChatParticipantsInvited, VideoChatScheduled, - VideoChatStarted, VideoNote, Voice, WebAppData, WriteAccessAllowed, + PhotoSize, Poll, ProximityAlertTriggered, Sticker, Story, SuccessfulPayment, ThreadId, True, + User, UserShared, Venue, Video, VideoChatEnded, VideoChatParticipantsInvited, + VideoChatScheduled, VideoChatStarted, VideoNote, Voice, WebAppData, WriteAccessAllowed, }; /// This object represents a message. @@ -366,6 +366,7 @@ pub enum MediaKind { Photo(MediaPhoto), Poll(MediaPoll), Sticker(MediaSticker), + Story(MediaStory), Text(MediaText), Video(MediaVideo), VideoNote(MediaVideoNote), @@ -494,6 +495,13 @@ pub struct MediaSticker { pub sticker: Sticker, } +#[serde_with_macros::skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct MediaStory { + /// Message is a forwarded story + pub story: Story, +} + #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaText { @@ -668,14 +676,14 @@ mod getters { use crate::types::{ self, message::MessageKind::*, Chat, ChatId, ChatMigration, Forward, ForwardedFrom, MediaAnimation, MediaAudio, MediaContact, MediaDocument, MediaGame, MediaKind, - MediaLocation, MediaPhoto, MediaPoll, MediaSticker, MediaText, MediaVenue, MediaVideo, - MediaVideoNote, MediaVoice, Message, MessageChannelChatCreated, MessageChatShared, - MessageCommon, MessageConnectedWebsite, MessageDeleteChatPhoto, MessageDice, MessageEntity, - MessageGroupChatCreated, MessageId, MessageInvoice, MessageLeftChatMember, - MessageNewChatMembers, MessageNewChatPhoto, MessageNewChatTitle, MessagePassportData, - MessagePinned, MessageProximityAlertTriggered, MessageSuccessfulPayment, - MessageSupergroupChatCreated, MessageUserShared, MessageVideoChatParticipantsInvited, - PhotoSize, User, + MediaLocation, MediaPhoto, MediaPoll, MediaSticker, MediaStory, MediaText, MediaVenue, + MediaVideo, MediaVideoNote, MediaVoice, Message, MessageChannelChatCreated, + MessageChatShared, MessageCommon, MessageConnectedWebsite, MessageDeleteChatPhoto, + MessageDice, MessageEntity, MessageGroupChatCreated, MessageId, MessageInvoice, + MessageLeftChatMember, MessageNewChatMembers, MessageNewChatPhoto, MessageNewChatTitle, + MessagePassportData, MessagePinned, MessageProximityAlertTriggered, + MessageSuccessfulPayment, MessageSupergroupChatCreated, MessageUserShared, + MessageVideoChatParticipantsInvited, PhotoSize, User, }; use super::{ @@ -899,6 +907,7 @@ mod getters { | MediaKind::Location(_) | MediaKind::Poll(_) | MediaKind::Sticker(_) + | MediaKind::Story(_) | MediaKind::Text(_) | MediaKind::VideoNote(_) | MediaKind::Voice(_) @@ -973,6 +982,17 @@ mod getters { } } + #[must_use] + pub fn story(&self) -> Option<&types::Story> { + match &self.kind { + Common(MessageCommon { + media_kind: MediaKind::Story(MediaStory { story, .. }), + .. + }) => Some(story), + _ => None, + } + } + #[must_use] pub fn video(&self) -> Option<&types::Video> { match &self.kind { diff --git a/crates/teloxide-core/src/types/story.rs b/crates/teloxide-core/src/types/story.rs new file mode 100644 index 00000000..86c84094 --- /dev/null +++ b/crates/teloxide-core/src/types/story.rs @@ -0,0 +1,5 @@ +use serde::{Deserialize, Serialize}; + +/// TBA 6.8: currently it holds no information +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Story; diff --git a/crates/teloxide/src/dispatching/filter_ext.rs b/crates/teloxide/src/dispatching/filter_ext.rs index c0ab8e04..532f614f 100644 --- a/crates/teloxide/src/dispatching/filter_ext.rs +++ b/crates/teloxide/src/dispatching/filter_ext.rs @@ -83,6 +83,7 @@ define_message_ext! { (filter_photo, Message::photo), (filter_poll, Message::poll), (filter_sticker, Message::sticker), + (filter_story, Message::story), (filter_text, Message::text), (filter_video, Message::video), (filter_video_note, Message::video_note),