Add the field story to the struct Message

This commit is contained in:
Сырцев Вадим Игоревич 2024-06-26 11:27:54 +03:00
parent 617197a1c7
commit 3016cbaf68
4 changed files with 39 additions and 11 deletions

View file

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

View file

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

View file

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

View file

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