From d9587ea562df99bdb8fdd457ac5bb8d2cab86e25 Mon Sep 17 00:00:00 2001 From: Andrey Brusnik Date: Tue, 16 Jul 2024 17:33:48 +0400 Subject: [PATCH] Add `GiveawayCompleted` struct --- crates/teloxide-core/src/types.rs | 2 ++ .../src/types/giveaway_completed.rs | 18 +++++++++++++ crates/teloxide-core/src/types/message.rs | 25 +++++++++++++------ 3 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 crates/teloxide-core/src/types/giveaway_completed.rs diff --git a/crates/teloxide-core/src/types.rs b/crates/teloxide-core/src/types.rs index ff89de7e..deb64378 100644 --- a/crates/teloxide-core/src/types.rs +++ b/crates/teloxide-core/src/types.rs @@ -42,6 +42,7 @@ pub use game_high_score::*; pub use general_forum_topic_hidden::*; pub use general_forum_topic_unhidden::*; pub use giveaway::*; +pub use giveaway_completed::*; pub use giveaway_created::*; pub use giveaway_winners::*; pub use inaccessible_message::*; @@ -178,6 +179,7 @@ mod game_high_score; mod general_forum_topic_hidden; mod general_forum_topic_unhidden; mod giveaway; +mod giveaway_completed; mod giveaway_created; mod giveaway_winners; mod inaccessible_message; diff --git a/crates/teloxide-core/src/types/giveaway_completed.rs b/crates/teloxide-core/src/types/giveaway_completed.rs new file mode 100644 index 00000000..face804d --- /dev/null +++ b/crates/teloxide-core/src/types/giveaway_completed.rs @@ -0,0 +1,18 @@ +use serde::{Deserialize, Serialize}; + +use crate::types::Message; + +/// This object represents a service message about the completion of a giveaway +/// without public winners. +#[serde_with::skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct GiveawayCompleted { + /// Number of winners in the giveaway + pub winner_count: u32, + + /// Number of undistributed prizes + pub unclaimed_prize_count: Option, + + /// Message with the giveaway that was completed, if it wasn't deleted + pub giveaway_message: Option>, +} diff --git a/crates/teloxide-core/src/types/message.rs b/crates/teloxide-core/src/types/message.rs index 24aafe08..e03fe262 100644 --- a/crates/teloxide-core/src/types/message.rs +++ b/crates/teloxide-core/src/types/message.rs @@ -7,13 +7,13 @@ use url::Url; use crate::types::{ Animation, Audio, BareChatId, Chat, ChatId, ChatShared, Contact, Dice, Document, ForumTopicClosed, ForumTopicCreated, ForumTopicEdited, ForumTopicReopened, Game, - GeneralForumTopicHidden, GeneralForumTopicUnhidden, Giveaway, GiveawayCreated, GiveawayWinners, - InlineKeyboardMarkup, Invoice, Location, MaybeInaccessibleMessage, - MessageAutoDeleteTimerChanged, MessageEntity, MessageEntityRef, MessageId, MessageOrigin, - PassportData, PhotoSize, Poll, ProximityAlertTriggered, Sticker, Story, SuccessfulPayment, - TextQuote, ThreadId, True, User, UsersShared, Venue, Video, VideoChatEnded, - VideoChatParticipantsInvited, VideoChatScheduled, VideoChatStarted, VideoNote, Voice, - WebAppData, WriteAccessAllowed, + GeneralForumTopicHidden, GeneralForumTopicUnhidden, Giveaway, GiveawayCompleted, + GiveawayCreated, GiveawayWinners, InlineKeyboardMarkup, Invoice, Location, + MaybeInaccessibleMessage, MessageAutoDeleteTimerChanged, MessageEntity, MessageEntityRef, + MessageId, MessageOrigin, PassportData, PhotoSize, Poll, ProximityAlertTriggered, Sticker, + Story, SuccessfulPayment, TextQuote, ThreadId, True, User, UsersShared, Venue, Video, + VideoChatEnded, VideoChatParticipantsInvited, VideoChatScheduled, VideoChatStarted, VideoNote, + Voice, WebAppData, WriteAccessAllowed, }; /// This object represents a message. @@ -78,6 +78,7 @@ pub enum MessageKind { GeneralForumTopicHidden(MessageGeneralForumTopicHidden), GeneralForumTopicUnhidden(MessageGeneralForumTopicUnhidden), Giveaway(MessageGiveaway), + GiveawayCompleted(MessageGiveawayCompleted), GiveawayCreated(MessageGiveawayCreated), GiveawayWinners(MessageGiveawayWinners), VideoChatScheduled(MessageVideoChatScheduled), @@ -606,6 +607,16 @@ pub struct MessageGiveaway { pub giveaway: Giveaway, } +#[serde_with::skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct MessageGiveawayCompleted { + /// Service message: a 'Giveaway' completed. [More about giveaways + /// »] + /// + /// [More about giveaways »]: https://core.telegram.org/api#giveaways-amp-gifts + pub giveaway_completed: GiveawayCompleted, +} + #[serde_with::skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessageGiveawayCreated {