use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct User {
pub id: i64,
pub is_bot: bool,
pub first_name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_premium: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub added_to_attachment_menu: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_join_groups: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_read_all_group_messages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub supports_inline_queries: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_connect_to_business: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub has_main_web_app: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub has_topics_enabled: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub allows_users_to_create_topics: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_bots: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub supports_guest_queries: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub supports_join_request_queries: Option<bool>,
}
impl User {
#[must_use]
pub fn full_name(&self) -> String {
match &self.last_name {
Some(last) => format!("{} {}", self.first_name, last),
None => self.first_name.clone(),
}
}
#[must_use]
pub fn mention(&self) -> Option<String> {
self.username.as_ref().map(|u| format!("@{u}"))
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserProfilePhotos {
pub total_count: u32,
pub photos: Vec<Vec<crate::file::PhotoSize>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserProfileAudios {
pub total_count: u32,
pub audios: Vec<crate::file::Audio>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum BotCommandScope {
Default,
AllPrivateChats,
AllGroupChats,
AllChatAdministrators,
Chat {
chat_id: ChatId,
},
ChatAdministrators {
chat_id: ChatId,
},
ChatMember {
chat_id: ChatId,
user_id: i64,
},
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct BotCommand {
pub command: String,
pub description: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_ephemeral: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChatId {
Id(i64),
Username(String),
}
impl From<i64> for ChatId {
fn from(id: i64) -> Self {
Self::Id(id)
}
}
impl From<&str> for ChatId {
fn from(username: &str) -> Self {
Self::Username(username.to_owned())
}
}
impl From<String> for ChatId {
fn from(username: String) -> Self {
Self::Username(username)
}
}
impl std::fmt::Display for ChatId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Id(id) => write!(f, "{id}"),
Self::Username(u) => write!(f, "{u}"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BotName {
pub name: 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, Default, Serialize, Deserialize)]
pub struct ChatAdministratorRights {
pub is_anonymous: bool,
pub can_manage_chat: bool,
pub can_delete_messages: bool,
pub can_manage_video_chats: bool,
pub can_restrict_members: bool,
pub can_promote_members: bool,
pub can_change_info: bool,
pub can_invite_users: bool,
pub can_post_stories: bool,
pub can_edit_stories: bool,
pub can_delete_stories: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_post_messages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_edit_messages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_pin_messages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_topics: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_direct_messages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_tags: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BotAccessSettings {
pub is_access_restricted: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub added_users: Option<Vec<User>>,
}