From fda1890425e7ee9065ae2f59d17163db05101beb Mon Sep 17 00:00:00 2001 From: Andrey Brusnik Date: Wed, 17 Jul 2024 00:37:10 +0400 Subject: [PATCH] Add `giveaway*` getters to `Message` --- crates/teloxide-core/src/types/message.rs | 41 ++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/crates/teloxide-core/src/types/message.rs b/crates/teloxide-core/src/types/message.rs index e03fe262..23bf79ed 100644 --- a/crates/teloxide-core/src/types/message.rs +++ b/crates/teloxide-core/src/types/message.rs @@ -692,7 +692,8 @@ mod getters { use super::{ MessageForumTopicClosed, MessageForumTopicCreated, MessageForumTopicEdited, MessageForumTopicReopened, MessageGeneralForumTopicHidden, - MessageGeneralForumTopicUnhidden, MessageMessageAutoDeleteTimerChanged, + MessageGeneralForumTopicUnhidden, MessageGiveaway, MessageGiveawayCompleted, + MessageGiveawayCreated, MessageGiveawayWinners, MessageMessageAutoDeleteTimerChanged, MessageVideoChatEnded, MessageVideoChatScheduled, MessageVideoChatStarted, MessageWebAppData, MessageWriteAccessAllowed, }; @@ -1413,6 +1414,44 @@ mod getters { } } + #[must_use] + pub fn giveaway(&self) -> Option<&types::Giveaway> { + match &self.kind { + Giveaway(MessageGiveaway { giveaway }) => Some(giveaway), + _ => None, + } + } + + #[must_use] + pub fn giveaway_completed(&self) -> Option<&types::GiveawayCompleted> { + match &self.kind { + GiveawayCompleted(MessageGiveawayCompleted { giveaway_completed }) => { + Some(giveaway_completed) + } + _ => None, + } + } + + #[must_use] + pub fn giveaway_created(&self) -> Option<&types::GiveawayCreated> { + match &self.kind { + GiveawayCreated(MessageGiveawayCreated { giveaway_created }) => { + Some(giveaway_created) + } + _ => None, + } + } + + #[must_use] + pub fn giveaway_winners(&self) -> Option<&types::GiveawayWinners> { + match &self.kind { + GiveawayWinners(MessageGiveawayWinners { giveaway_winners }) => { + Some(giveaway_winners) + } + _ => None, + } + } + #[must_use] pub fn video_chat_scheduled(&self) -> Option<&types::VideoChatScheduled> { match &self.kind {