mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Add Giveaway
struct
This commit is contained in:
parent
c0f97fae0e
commit
62da0027e3
3 changed files with 64 additions and 6 deletions
|
@ -41,6 +41,7 @@ pub use game::*;
|
||||||
pub use game_high_score::*;
|
pub use game_high_score::*;
|
||||||
pub use general_forum_topic_hidden::*;
|
pub use general_forum_topic_hidden::*;
|
||||||
pub use general_forum_topic_unhidden::*;
|
pub use general_forum_topic_unhidden::*;
|
||||||
|
pub use giveaway::*;
|
||||||
pub use inaccessible_message::*;
|
pub use inaccessible_message::*;
|
||||||
pub use inline_keyboard_button::*;
|
pub use inline_keyboard_button::*;
|
||||||
pub use inline_keyboard_markup::*;
|
pub use inline_keyboard_markup::*;
|
||||||
|
@ -174,6 +175,7 @@ mod game;
|
||||||
mod game_high_score;
|
mod game_high_score;
|
||||||
mod general_forum_topic_hidden;
|
mod general_forum_topic_hidden;
|
||||||
mod general_forum_topic_unhidden;
|
mod general_forum_topic_unhidden;
|
||||||
|
mod giveaway;
|
||||||
mod inaccessible_message;
|
mod inaccessible_message;
|
||||||
mod inline_keyboard_button;
|
mod inline_keyboard_button;
|
||||||
mod inline_keyboard_markup;
|
mod inline_keyboard_markup;
|
||||||
|
|
45
crates/teloxide-core/src/types/giveaway.rs
Normal file
45
crates/teloxide-core/src/types/giveaway.rs
Normal file
|
@ -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<Chat>,
|
||||||
|
|
||||||
|
/// 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<Utc>,
|
||||||
|
|
||||||
|
/// 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<String>,
|
||||||
|
|
||||||
|
/// 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<Vec<String>>,
|
||||||
|
|
||||||
|
/// The number of months the Telegram Premium subscription won from the
|
||||||
|
/// giveaway will be active for
|
||||||
|
pub premium_subscription_month_count: Option<u8>,
|
||||||
|
}
|
|
@ -7,12 +7,12 @@ use url::Url;
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
Animation, Audio, BareChatId, Chat, ChatId, ChatShared, Contact, Dice, Document,
|
Animation, Audio, BareChatId, Chat, ChatId, ChatShared, Contact, Dice, Document,
|
||||||
ForumTopicClosed, ForumTopicCreated, ForumTopicEdited, ForumTopicReopened, Game,
|
ForumTopicClosed, ForumTopicCreated, ForumTopicEdited, ForumTopicReopened, Game,
|
||||||
GeneralForumTopicHidden, GeneralForumTopicUnhidden, InlineKeyboardMarkup, Invoice, Location,
|
GeneralForumTopicHidden, GeneralForumTopicUnhidden, Giveaway, InlineKeyboardMarkup, Invoice,
|
||||||
MaybeInaccessibleMessage, MessageAutoDeleteTimerChanged, MessageEntity, MessageEntityRef,
|
Location, MaybeInaccessibleMessage, MessageAutoDeleteTimerChanged, MessageEntity,
|
||||||
MessageId, MessageOrigin, PassportData, PhotoSize, Poll, ProximityAlertTriggered, Sticker,
|
MessageEntityRef, MessageId, MessageOrigin, PassportData, PhotoSize, Poll,
|
||||||
Story, SuccessfulPayment, TextQuote, ThreadId, True, User, UsersShared, Venue, Video,
|
ProximityAlertTriggered, Sticker, Story, SuccessfulPayment, TextQuote, ThreadId, True, User,
|
||||||
VideoChatEnded, VideoChatParticipantsInvited, VideoChatScheduled, VideoChatStarted, VideoNote,
|
UsersShared, Venue, Video, VideoChatEnded, VideoChatParticipantsInvited, VideoChatScheduled,
|
||||||
Voice, WebAppData, WriteAccessAllowed,
|
VideoChatStarted, VideoNote, Voice, WebAppData, WriteAccessAllowed,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This object represents a message.
|
/// This object represents a message.
|
||||||
|
@ -76,6 +76,7 @@ pub enum MessageKind {
|
||||||
ForumTopicReopened(MessageForumTopicReopened),
|
ForumTopicReopened(MessageForumTopicReopened),
|
||||||
GeneralForumTopicHidden(MessageGeneralForumTopicHidden),
|
GeneralForumTopicHidden(MessageGeneralForumTopicHidden),
|
||||||
GeneralForumTopicUnhidden(MessageGeneralForumTopicUnhidden),
|
GeneralForumTopicUnhidden(MessageGeneralForumTopicUnhidden),
|
||||||
|
Giveaway(MessageGiveaway),
|
||||||
VideoChatScheduled(MessageVideoChatScheduled),
|
VideoChatScheduled(MessageVideoChatScheduled),
|
||||||
VideoChatStarted(MessageVideoChatStarted),
|
VideoChatStarted(MessageVideoChatStarted),
|
||||||
VideoChatEnded(MessageVideoChatEnded),
|
VideoChatEnded(MessageVideoChatEnded),
|
||||||
|
@ -592,6 +593,16 @@ pub struct MessageGeneralForumTopicUnhidden {
|
||||||
pub general_forum_topic_unhidden: GeneralForumTopicUnhidden,
|
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]
|
#[serde_with::skip_serializing_none]
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct MessageVideoChatScheduled {
|
pub struct MessageVideoChatScheduled {
|
||||||
|
|
Loading…
Reference in a new issue