use serde::{Deserialize, Serialize};
use super::chat::UserInfo;
use super::content::{FileSource, ParseMode};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SendPoll {
pub question: String,
pub options: Vec<String>,
pub is_anonymous: bool,
pub poll_type: PollType,
pub correct_option_id: Option<usize>,
pub explanation: Option<String>,
pub open_period: Option<i32>,
pub allows_multiple_answers: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum PollType {
Regular,
Quiz,
}
impl Default for SendPoll {
fn default() -> Self {
Self {
question: String::new(),
options: Vec::new(),
is_anonymous: true,
poll_type: PollType::Regular,
correct_option_id: None,
explanation: None,
open_period: None,
allows_multiple_answers: false,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum DiceEmoji {
#[default]
Dice,
Darts,
Basketball,
Football,
SlotMachine,
Bowling,
}
impl DiceEmoji {
pub fn as_str(&self) -> &'static str {
match self {
Self::Dice => "\u{1f3b2}",
Self::Darts => "\u{1f3af}",
Self::Basketball => "\u{1f3c0}",
Self::Football => "\u{26bd}",
Self::SlotMachine => "\u{1f3b0}",
Self::Bowling => "\u{1f3b3}",
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Contact {
pub phone_number: String,
pub first_name: String,
pub last_name: Option<String>,
pub user_id: Option<u64>,
pub vcard: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Venue {
pub latitude: f64,
pub longitude: f64,
pub title: String,
pub address: String,
pub foursquare_id: Option<String>,
pub foursquare_type: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChatMember {
pub user: UserInfo,
pub status: ChatMemberStatus,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ChatMemberStatus {
Creator,
Administrator,
Member,
Restricted,
Left,
Banned,
}
impl ChatMemberStatus {
pub fn is_admin(&self) -> bool {
matches!(self, Self::Creator | Self::Administrator)
}
pub fn is_member(&self) -> bool {
matches!(
self,
Self::Creator | Self::Administrator | Self::Member | Self::Restricted
)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChatInfo {
pub id: super::ChatId,
pub chat_type: ChatType,
pub title: Option<String>,
pub username: Option<String>,
pub first_name: Option<String>,
pub last_name: Option<String>,
pub member_count: Option<i32>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ChatType {
Private,
Group,
Supergroup,
Channel,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BotCommand {
pub command: String,
pub description: String,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ChatPermissions {
pub can_send_messages: Option<bool>,
pub can_send_media_messages: Option<bool>,
pub can_send_polls: Option<bool>,
pub can_send_other_messages: Option<bool>,
pub can_add_web_page_previews: Option<bool>,
pub can_change_info: Option<bool>,
pub can_invite_users: Option<bool>,
pub can_pin_messages: Option<bool>,
}
#[derive(Debug, Clone)]
pub struct Invoice {
pub title: String,
pub description: String,
pub payload: String,
pub provider_token: Option<String>,
pub currency: String,
pub prices: Vec<(String, i64)>,
pub start_parameter: Option<String>,
pub photo_url: Option<String>,
pub need_name: bool,
pub need_phone_number: bool,
pub need_email: bool,
pub need_shipping_address: bool,
pub is_flexible: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MediaGroupItem {
Photo {
source: FileSource,
caption: Option<String>,
parse_mode: ParseMode,
spoiler: bool,
},
Video {
source: FileSource,
caption: Option<String>,
parse_mode: ParseMode,
spoiler: bool,
},
Document {
source: FileSource,
caption: Option<String>,
parse_mode: ParseMode,
},
Audio {
source: FileSource,
caption: Option<String>,
parse_mode: ParseMode,
},
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DownloadedFile {
pub data: Vec<u8>,
pub file_size: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BotInfo {
pub id: super::UserId,
pub username: String,
pub first_name: String,
pub can_join_groups: bool,
pub can_read_all_group_messages: bool,
pub supports_inline_queries: bool,
}
#[derive(Debug, Clone)]
pub struct UserProfilePhotos {
pub total_count: i32,
pub photos: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChatInviteLink {
pub invite_link: String,
pub creator: Option<UserInfo>,
pub creates_join_request: bool,
pub is_primary: bool,
pub is_revoked: bool,
pub name: Option<String>,
pub expire_date: Option<i64>,
pub member_limit: Option<i32>,
pub pending_join_request_count: Option<i32>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MenuButton {
Default,
Commands,
WebApp {
text: String,
url: String,
},
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BotDescription {
pub description: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BotShortDescription {
pub short_description: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BotName {
pub name: String,
}
#[derive(Debug, Clone)]
pub struct ShippingOption {
pub id: String,
pub title: String,
pub prices: Vec<(String, i64)>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ForumTopic {
pub id: i32,
pub title: String,
pub icon_color: Option<i32>,
pub icon_custom_emoji_id: Option<String>,
pub is_closed: bool,
pub is_hidden: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StarTransaction {
pub id: String,
pub amount: i64,
pub nanos: i32,
pub date: i32,
pub source: StarTransactionPeer,
pub title: Option<String>,
pub description: Option<String>,
pub is_refund: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum StarTransactionPeer {
User(super::UserId),
AppStore,
PlayMarket,
Fragment,
PremiumBot,
Ads,
Api,
Unknown,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StarBalance {
pub amount: i64,
pub nanos: i32,
}
#[derive(Debug, Clone)]
pub struct StarTransactions {
pub balance: StarBalance,
pub transactions: Vec<StarTransaction>,
pub next_offset: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PaidMediaInput {
Photo {
source: FileSource,
},
Video {
source: FileSource,
duration: Option<i32>,
width: Option<i32>,
height: Option<i32>,
supports_streaming: Option<bool>,
},
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChecklistItem {
pub text: String,
pub checked: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserProfileAudios {
pub total_count: i32,
pub audios: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BusinessConnection {
pub id: String,
pub user: UserInfo,
pub user_chat_id: super::ChatId,
pub date: i64,
pub can_reply: bool,
pub is_enabled: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AcceptedGiftTypes {
pub unlimited_gifts: bool,
pub limited_gifts: bool,
pub unique_gifts: bool,
pub premium_subscription: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Gift {
pub id: String,
pub sticker_file_id: String,
pub star_count: i64,
pub total_count: Option<i64>,
pub remaining_count: Option<i64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OwnedGift {
pub gift_id: String,
pub owned_gift_id: String,
pub sender_user: Option<UserInfo>,
pub text: Option<String>,
pub is_saved: bool,
pub is_sold: bool,
pub convert_star_count: Option<i64>,
pub upgrade_star_count: Option<i64>,
pub date: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OwnedGifts {
pub total_count: i32,
pub gifts: Vec<OwnedGift>,
pub next_offset: Option<String>,
}
#[derive(Debug, Clone)]
pub enum StoryContent {
Photo {
photo: FileSource,
},
Video {
video: FileSource,
duration: Option<f64>,
},
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Story {
pub id: i32,
pub chat_id: super::ChatId,
pub date: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserChatBoosts {
pub boosts: Vec<ChatBoost>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChatBoost {
pub boost_id: String,
pub add_date: i64,
pub expiration_date: i64,
pub source: ChatBoostSource,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ChatBoostSource {
Premium {
user: UserInfo,
},
GiftCode {
user: UserInfo,
},
Giveaway {
giveaway_message_id: Option<i32>,
user: Option<UserInfo>,
is_unclaimed: bool,
},
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PreparedKeyboardButtonData {
pub button_type: PreparedKeyboardButtonType,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PreparedKeyboardButtonType {
RequestUsers {
request_id: i32,
user_is_bot: Option<bool>,
user_is_premium: Option<bool>,
max_quantity: Option<i32>,
},
RequestChat {
request_id: i32,
chat_is_channel: bool,
},
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PreparedKeyboardButton {
pub id: String,
pub expiration_date: i64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum StickerFormat {
Static,
Animated,
Video,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum StickerType {
Regular,
Mask,
CustomEmoji,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct MaskPosition {
pub point: MaskPoint,
pub x_shift: f64,
pub y_shift: f64,
pub scale: f64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MaskPoint {
Forehead,
Eyes,
Mouth,
Chin,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StickerInfo {
pub file_id: String,
pub file_unique_id: String,
pub sticker_type: StickerType,
pub width: i32,
pub height: i32,
pub is_animated: bool,
pub is_video: bool,
pub emoji: Option<String>,
pub set_name: Option<String>,
pub mask_position: Option<MaskPosition>,
pub custom_emoji_id: Option<String>,
pub file_size: Option<i64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StickerSet {
pub name: String,
pub title: String,
pub sticker_type: StickerType,
pub stickers: Vec<StickerInfo>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputSticker {
pub sticker: FileSource,
pub format: StickerFormat,
pub emoji_list: Vec<String>,
pub mask_position: Option<MaskPosition>,
pub keywords: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TelegramFile {
pub file_id: String,
pub file_unique_id: String,
pub file_size: Option<i64>,
pub file_path: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GameHighScore {
pub position: i32,
pub user: UserInfo,
pub score: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SentWebAppMessage {
pub inline_message_id: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PreparedInlineMessage {
pub id: String,
pub expiration_date: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PassportElementError {
DataField {
element_type: String,
field_name: String,
data_hash: String,
message: String,
},
FrontSide {
element_type: String,
file_hash: String,
message: String,
},
ReverseSide {
element_type: String,
file_hash: String,
message: String,
},
Selfie {
element_type: String,
file_hash: String,
message: String,
},
File {
element_type: String,
file_hash: String,
message: String,
},
Files {
element_type: String,
file_hashes: Vec<String>,
message: String,
},
TranslationFile {
element_type: String,
file_hash: String,
message: String,
},
TranslationFiles {
element_type: String,
file_hashes: Vec<String>,
message: String,
},
Unspecified {
element_type: String,
element_hash: String,
message: String,
},
}