diff --git a/crates/teloxide-core/src/types.rs b/crates/teloxide-core/src/types.rs index 707eb90f..6fc26cab 100644 --- a/crates/teloxide-core/src/types.rs +++ b/crates/teloxide-core/src/types.rs @@ -41,6 +41,7 @@ pub use game::*; pub use game_high_score::*; pub use general_forum_topic_hidden::*; pub use general_forum_topic_unhidden::*; +pub use giveaway::*; pub use inaccessible_message::*; pub use inline_keyboard_button::*; pub use inline_keyboard_markup::*; @@ -174,6 +175,7 @@ mod game; mod game_high_score; mod general_forum_topic_hidden; mod general_forum_topic_unhidden; +mod giveaway; mod inaccessible_message; mod inline_keyboard_button; mod inline_keyboard_markup; diff --git a/crates/teloxide-core/src/types/giveaway.rs b/crates/teloxide-core/src/types/giveaway.rs new file mode 100644 index 00000000..da0e6ffd --- /dev/null +++ b/crates/teloxide-core/src/types/giveaway.rs @@ -0,0 +1,45 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; + +use crate::types::Chat; + +/// This object represents a message about a scheduled giveaway. +#[serde_with::skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Giveaway { + /// The list of chats which the user must join to participate in the + /// giveaway. + pub chats: Vec, + + /// Point in time (Unix timestamp) when winners of the giveaway will be + /// selected + #[serde(with = "crate::types::serde_date_from_unix_timestamp")] + pub winners_selection_date: DateTime, + + /// The number of users which are supposed to be selected as winners of the + /// giveaway + pub winner_count: u32, + + /// `true`, if only users who join the chats after the giveaway started + /// should be eligible to win + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub only_new_members: bool, + + /// `true`, if the list of giveaway winners will be visible to everyone + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub has_public_winners: bool, + + /// Description of additional giveaway prize + pub prize_description: Option, + + /// A list of two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country codes indicating the + /// countries from which eligible users for the giveaway must come. If + /// empty, then all users can participate in the giveaway. Users with a + /// phone number that was bought on Fragment can always participate in + /// giveaways. + pub country_codes: Option>, + + /// The number of months the Telegram Premium subscription won from the + /// giveaway will be active for + pub premium_subscription_month_count: Option, +} diff --git a/crates/teloxide-core/src/types/message.rs b/crates/teloxide-core/src/types/message.rs index ccbacbe5..3c097084 100644 --- a/crates/teloxide-core/src/types/message.rs +++ b/crates/teloxide-core/src/types/message.rs @@ -7,12 +7,12 @@ use url::Url; use crate::types::{ Animation, Audio, BareChatId, Chat, ChatId, ChatShared, Contact, Dice, Document, ForumTopicClosed, ForumTopicCreated, ForumTopicEdited, ForumTopicReopened, Game, - GeneralForumTopicHidden, GeneralForumTopicUnhidden, 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, 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. @@ -76,6 +76,7 @@ pub enum MessageKind { ForumTopicReopened(MessageForumTopicReopened), GeneralForumTopicHidden(MessageGeneralForumTopicHidden), GeneralForumTopicUnhidden(MessageGeneralForumTopicUnhidden), + Giveaway(MessageGiveaway), VideoChatScheduled(MessageVideoChatScheduled), VideoChatStarted(MessageVideoChatStarted), VideoChatEnded(MessageVideoChatEnded), @@ -592,6 +593,16 @@ pub struct MessageGeneralForumTopicUnhidden { pub general_forum_topic_unhidden: GeneralForumTopicUnhidden, } +#[serde_with::skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct MessageGiveaway { + /// Message is giveaway, information about a scheduled giveaway. [More about + /// giveaways »] + /// + /// [More about giveaways »]: https://core.telegram.org/api#giveaways-amp-gifts + pub giveaway: Giveaway, +} + #[serde_with::skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessageVideoChatScheduled {