Skip to content

Commit

Permalink
Bot API 7.0: Giveaway (#134)
Browse files Browse the repository at this point in the history
* Bot API 7.0: Giveaway

* Bot API 7.0: Other changes (#135)
  • Loading branch information
ayrat555 authored Jan 6, 2024
1 parent 8b97179 commit 2a48944
Showing 1 changed file with 70 additions and 23 deletions.
93 changes: 70 additions & 23 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,22 @@ pub struct Chat {
#[builder(setter(into, strip_option), default)]
pub available_reactions: Option<Vec<ReactionType>>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub accent_color_id: Option<u16>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub background_custom_emoji_id: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub profile_accent_color_id: Option<u16>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub profile_background_custom_emoji_id: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub emoji_status_custom_emoji_id: Option<String>,
Expand Down Expand Up @@ -567,6 +583,10 @@ pub struct Chat {
#[builder(setter(into, strip_option), default)]
pub has_protected_content: Option<bool>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub has_visible_history: Option<bool>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub sticker_set_name: Option<String>,
Expand Down Expand Up @@ -607,27 +627,7 @@ pub struct Message {

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub forward_from: Option<Box<User>>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub forward_from_chat: Option<Box<Chat>>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub forward_from_message_id: Option<i32>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub forward_signature: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub forward_sender_name: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub forward_date: Option<u64>,
pub forward_origin: Option<Box<MessageOrigin>>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
Expand Down Expand Up @@ -799,7 +799,7 @@ pub struct Message {

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub pinned_message: Option<Box<Message>>,
pub pinned_message: Option<Box<MaybeInaccessibleMessage>>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
Expand Down Expand Up @@ -857,6 +857,22 @@ pub struct Message {
#[builder(setter(into, strip_option), default)]
pub general_forum_topic_unhidden: Option<Box<GeneralForumTopicUnhidden>>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub giveaway_created: Option<GiveawayCreated>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub giveaway: Option<Giveaway>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub giveaway_winners: Option<GiveawayWinners>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub giveaway_completed: Option<GiveawayCompleted>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub video_chat_started: Option<Box<VideoChatStarted>>,
Expand Down Expand Up @@ -1745,7 +1761,7 @@ pub struct CallbackQuery {

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub message: Option<Message>,
pub message: Option<MaybeInaccessibleMessage>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
Expand Down Expand Up @@ -3468,6 +3484,9 @@ pub struct GameHighScore {
pub score: i32,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
pub struct GiveawayCreated {}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
pub struct Giveaway {
pub chats: Vec<Chat>,
Expand Down Expand Up @@ -3534,6 +3553,19 @@ pub struct GiveawayWinners {
pub prize_description: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
pub struct GiveawayCompleted {
pub winner_count: u32,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub unclaimed_prize_count: Option<u32>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub giveaway_message: Option<Box<Message>>,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Builder)]
pub struct ChatAdministratorRights {
pub is_anonymous: bool,
Expand Down Expand Up @@ -3669,6 +3701,21 @@ pub struct UserChatBoosts {
pub boosts: Vec<ChatBoost>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum MaybeInaccessibleMessage {
Message(Message),
InaccessibleMessage(InaccessibleMessage),
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
pub struct InaccessibleMessage {
pub chat: Chat,

pub message_id: i32,

pub date: u64,
}

#[cfg(test)]
mod serde_tests {
use super::*;
Expand Down

0 comments on commit 2a48944

Please sign in to comment.