Skip to main content

rustigram_types/
giveaway.rs

1use serde::{Deserialize, Serialize};
2
3use crate::chat::Chat;
4use crate::message::Message;
5use crate::user::User;
6
7/// Service message: a scheduled giveaway was created.
8#[derive(Debug, Clone, Default, Serialize, Deserialize)]
9#[non_exhaustive]
10pub struct GiveawayCreated {
11    /// Number of Telegram Stars to be split among winners; Star giveaways only.
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub prize_star_count: Option<i64>,
14}
15
16/// A scheduled giveaway.
17#[derive(Debug, Clone, Default, Serialize, Deserialize)]
18#[non_exhaustive]
19pub struct Giveaway {
20    /// The chats the user must join to take part.
21    pub chats: Vec<Chat>,
22    /// Point in time when winners will be selected, as a Unix timestamp.
23    pub winners_selection_date: i64,
24    /// Number of users who will be selected as winners.
25    pub winner_count: u32,
26    /// `true` if only users who join the chats after the giveaway started
27    /// should be eligible.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub only_new_members: Option<bool>,
30    /// `true` if the list of winners will be visible to everyone.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub has_public_winners: Option<bool>,
33    /// Description of additional giveaway prizes.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub prize_description: Option<String>,
36    /// Two-letter ISO 3166-1 alpha-2 country codes of eligible users.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub country_codes: Option<Vec<String>>,
39    /// Number of Telegram Stars to be split among winners; Star giveaways only.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub prize_star_count: Option<i64>,
42    /// Number of months the Telegram Premium subscription won will be active
43    /// for; Premium giveaways only.
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub premium_subscription_month_count: Option<u32>,
46}
47
48/// Service message: giveaway winners were selected.
49#[derive(Debug, Clone, Default, Serialize, Deserialize)]
50#[non_exhaustive]
51pub struct GiveawayWinners {
52    /// The chat that created the giveaway.
53    pub chat: Chat,
54    /// Identifier of the message with the giveaway in the chat.
55    pub giveaway_message_id: i64,
56    /// Point in time when winners were selected, as a Unix timestamp.
57    pub winners_selection_date: i64,
58    /// Total number of winners.
59    pub winner_count: u32,
60    /// The users who won the giveaway, up to 100.
61    pub winners: Vec<User>,
62    /// Number of other chats the user had to join to take part.
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub additional_chat_count: Option<u32>,
65    /// Number of Telegram Stars split among winners; Star giveaways only.
66    #[serde(skip_serializing_if = "Option::is_none")]
67    pub prize_star_count: Option<i64>,
68    /// Number of months the won Premium subscription is active for.
69    #[serde(skip_serializing_if = "Option::is_none")]
70    pub premium_subscription_month_count: Option<u32>,
71    /// Number of undistributed prizes.
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub unclaimed_prize_count: Option<u32>,
74    /// `true` if only users who joined after the giveaway started were eligible.
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub only_new_members: Option<bool>,
77    /// `true` if the giveaway was cancelled because the payment was refunded.
78    #[serde(skip_serializing_if = "Option::is_none")]
79    pub was_refunded: Option<bool>,
80    /// Description of additional giveaway prizes.
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub prize_description: Option<String>,
83}
84
85/// Service message: a giveaway without public winners has completed.
86#[derive(Debug, Clone, Default, Serialize, Deserialize)]
87#[non_exhaustive]
88pub struct GiveawayCompleted {
89    /// Number of winners in the giveaway.
90    pub winner_count: u32,
91    /// Number of undistributed prizes.
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub unclaimed_prize_count: Option<u32>,
94    /// The message with the giveaway that was completed.
95    ///
96    /// Boxed because [`Message`] transitively contains this type, and an
97    /// unboxed cycle would make the struct infinitely sized.
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub giveaway_message: Option<Box<Message>>,
100    /// `true` if the giveaway is a Telegram Star giveaway.
101    #[serde(skip_serializing_if = "Option::is_none")]
102    pub is_star_giveaway: Option<bool>,
103}