mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 06:25:10 +01:00
Add GiveawayWinners
struct
This commit is contained in:
parent
fa1b793c7f
commit
9d803693fb
3 changed files with 69 additions and 1 deletions
|
@ -43,6 +43,7 @@ pub use general_forum_topic_hidden::*;
|
|||
pub use general_forum_topic_unhidden::*;
|
||||
pub use giveaway::*;
|
||||
pub use giveaway_created::*;
|
||||
pub use giveaway_winners::*;
|
||||
pub use inaccessible_message::*;
|
||||
pub use inline_keyboard_button::*;
|
||||
pub use inline_keyboard_markup::*;
|
||||
|
@ -178,6 +179,7 @@ mod general_forum_topic_hidden;
|
|||
mod general_forum_topic_unhidden;
|
||||
mod giveaway;
|
||||
mod giveaway_created;
|
||||
mod giveaway_winners;
|
||||
mod inaccessible_message;
|
||||
mod inline_keyboard_button;
|
||||
mod inline_keyboard_markup;
|
||||
|
|
55
crates/teloxide-core/src/types/giveaway_winners.rs
Normal file
55
crates/teloxide-core/src/types/giveaway_winners.rs
Normal file
|
@ -0,0 +1,55 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::with_prefix;
|
||||
|
||||
use crate::types::{Chat, MessageId, User};
|
||||
|
||||
with_prefix!(prefix_giveaway "giveaway_");
|
||||
|
||||
/// This object represents a message about the completion of a giveaway with
|
||||
/// public winners.
|
||||
#[serde_with::skip_serializing_none]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct GiveawayWinners {
|
||||
/// The chat that created the giveaway
|
||||
pub chat: Chat,
|
||||
|
||||
/// Identifier of the messsage with the giveaway in the chat
|
||||
#[serde(flatten, with = "prefix_giveaway")]
|
||||
pub giveaway_message_id: MessageId,
|
||||
|
||||
/// Point in time (Unix timestamp) when winners of the giveaway were
|
||||
/// selected
|
||||
#[serde(with = "crate::types::serde_date_from_unix_timestamp")]
|
||||
pub winners_selection_date: DateTime<Utc>,
|
||||
|
||||
/// Total number of winners in the giveaway
|
||||
pub winner_count: u32,
|
||||
|
||||
/// List of up to 100 winners of the giveaway
|
||||
pub winners: Vec<User>,
|
||||
|
||||
/// The number of other chats the user had to join in order to be eligible
|
||||
/// for the giveaway
|
||||
pub additional_chat_count: Option<u16>,
|
||||
|
||||
/// The number of months the Telegram Premium subscription won from the
|
||||
/// giveaway will be active for
|
||||
pub premium_subscription_month_count: Option<u8>,
|
||||
|
||||
/// Number of undistributed prizes
|
||||
pub unclaimed_prize_count: Option<u32>,
|
||||
|
||||
/// `true`, if only users who had joined the chats after the giveaway
|
||||
/// started were eligible to win
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub only_new_members: bool,
|
||||
|
||||
/// `true`, if the giveaway was canceled because the payment for it was
|
||||
/// refunded
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub was_refunded: bool,
|
||||
|
||||
/// Description of additional giveaway prize
|
||||
pub prize_description: Option<String>,
|
||||
}
|
|
@ -7,7 +7,7 @@ use url::Url;
|
|||
use crate::types::{
|
||||
Animation, Audio, BareChatId, Chat, ChatId, ChatShared, Contact, Dice, Document,
|
||||
ForumTopicClosed, ForumTopicCreated, ForumTopicEdited, ForumTopicReopened, Game,
|
||||
GeneralForumTopicHidden, GeneralForumTopicUnhidden, Giveaway, GiveawayCreated,
|
||||
GeneralForumTopicHidden, GeneralForumTopicUnhidden, Giveaway, GiveawayCreated, GiveawayWinners,
|
||||
InlineKeyboardMarkup, Invoice, Location, MaybeInaccessibleMessage,
|
||||
MessageAutoDeleteTimerChanged, MessageEntity, MessageEntityRef, MessageId, MessageOrigin,
|
||||
PassportData, PhotoSize, Poll, ProximityAlertTriggered, Sticker, Story, SuccessfulPayment,
|
||||
|
@ -79,6 +79,7 @@ pub enum MessageKind {
|
|||
GeneralForumTopicUnhidden(MessageGeneralForumTopicUnhidden),
|
||||
Giveaway(MessageGiveaway),
|
||||
GiveawayCreated(MessageGiveawayCreated),
|
||||
GiveawayWinners(MessageGiveawayWinners),
|
||||
VideoChatScheduled(MessageVideoChatScheduled),
|
||||
VideoChatStarted(MessageVideoChatStarted),
|
||||
VideoChatEnded(MessageVideoChatEnded),
|
||||
|
@ -615,6 +616,16 @@ pub struct MessageGiveawayCreated {
|
|||
pub giveaway_created: GiveawayCreated,
|
||||
}
|
||||
|
||||
#[serde_with::skip_serializing_none]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageGiveawayWinners {
|
||||
/// Message is giveaway winners, information about the completion of a
|
||||
/// giveaway with public winners. [More about giveaways »]
|
||||
///
|
||||
/// [More about giveaways »]: https://core.telegram.org/api#giveaways-amp-gifts
|
||||
pub giveaway_winners: GiveawayWinners,
|
||||
}
|
||||
|
||||
#[serde_with::skip_serializing_none]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageVideoChatScheduled {
|
||||
|
|
Loading…
Reference in a new issue