From 1abf1fa519359fb1b4e2a8a94fbb91890f68d068 Mon Sep 17 00:00:00 2001 From: Andrey Brusnik Date: Fri, 19 Jul 2024 02:06:18 +0400 Subject: [PATCH] Add `link_preview_options` getter to `Message` --- crates/teloxide-core/src/types/message.rs | 31 +++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/crates/teloxide-core/src/types/message.rs b/crates/teloxide-core/src/types/message.rs index a4b4372f..a375597e 100644 --- a/crates/teloxide-core/src/types/message.rs +++ b/crates/teloxide-core/src/types/message.rs @@ -681,16 +681,16 @@ mod getters { use std::ops::Deref; use crate::types::{ - self, message::MessageKind::*, Chat, ChatId, ChatMigration, MaybeInaccessibleMessage, - MediaAnimation, MediaAudio, MediaContact, MediaDocument, MediaGame, MediaKind, - 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, - MessageOrigin, MessagePassportData, MessagePinned, MessageProximityAlertTriggered, - MessageSuccessfulPayment, MessageSupergroupChatCreated, MessageUsersShared, - MessageVideoChatParticipantsInvited, PhotoSize, TextQuote, User, + self, message::MessageKind::*, Chat, ChatId, ChatMigration, LinkPreviewOptions, + MaybeInaccessibleMessage, MediaAnimation, MediaAudio, MediaContact, MediaDocument, + MediaGame, MediaKind, 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, MessageOrigin, MessagePassportData, MessagePinned, + MessageProximityAlertTriggered, MessageSuccessfulPayment, MessageSupergroupChatCreated, + MessageUsersShared, MessageVideoChatParticipantsInvited, PhotoSize, TextQuote, User, }; use super::{ @@ -870,6 +870,17 @@ mod getters { } } + #[must_use] + pub fn link_preview_options(&self) -> Option<&LinkPreviewOptions> { + match &self.kind { + Common(MessageCommon { + media_kind: MediaKind::Text(MediaText { link_preview_options, .. }), + .. + }) => link_preview_options.as_ref(), + _ => None, + } + } + /// Returns message entities that represent text formatting. /// /// **Note:** you probably want to use [`parse_caption_entities`]