Add giveaway* getters to Message

This commit is contained in:
Andrey Brusnik 2024-07-17 00:37:10 +04:00
parent d9587ea562
commit fda1890425
No known key found for this signature in database
GPG key ID: D33232F28CFF442C

View file

@ -692,7 +692,8 @@ mod getters {
use super::{ use super::{
MessageForumTopicClosed, MessageForumTopicCreated, MessageForumTopicEdited, MessageForumTopicClosed, MessageForumTopicCreated, MessageForumTopicEdited,
MessageForumTopicReopened, MessageGeneralForumTopicHidden, MessageForumTopicReopened, MessageGeneralForumTopicHidden,
MessageGeneralForumTopicUnhidden, MessageMessageAutoDeleteTimerChanged, MessageGeneralForumTopicUnhidden, MessageGiveaway, MessageGiveawayCompleted,
MessageGiveawayCreated, MessageGiveawayWinners, MessageMessageAutoDeleteTimerChanged,
MessageVideoChatEnded, MessageVideoChatScheduled, MessageVideoChatStarted, MessageVideoChatEnded, MessageVideoChatScheduled, MessageVideoChatStarted,
MessageWebAppData, MessageWriteAccessAllowed, 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] #[must_use]
pub fn video_chat_scheduled(&self) -> Option<&types::VideoChatScheduled> { pub fn video_chat_scheduled(&self) -> Option<&types::VideoChatScheduled> {
match &self.kind { match &self.kind {