use serde::{Deserialize, Serialize};
use crate::utils::deserialize_utils::is_false;
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SwitchInlineQueryChosenChat {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub query: Option<String>,
#[serde(default, skip_serializing_if = "is_false")]
pub allow_user_chats: bool,
#[serde(default, skip_serializing_if = "is_false")]
pub allow_bot_chats: bool,
#[serde(default, skip_serializing_if = "is_false")]
pub allow_group_chats: bool,
#[serde(default, skip_serializing_if = "is_false")]
pub allow_channel_chats: bool,
}
impl<T: Into<Option<String>>> From<T> for SwitchInlineQueryChosenChat {
fn from(value: T) -> Self {
Self {
query: value.into(),
allow_user_chats: true,
allow_bot_chats: true,
allow_group_chats: true,
allow_channel_chats: true,
}
}
}
impl SwitchInlineQueryChosenChat {
pub fn new(
query: impl Into<Option<String>>,
allow_user_chats: bool,
allow_bot_chats: bool,
allow_group_chats: bool,
allow_channel_chats: bool,
) -> Self {
Self {
query: query.into(),
allow_user_chats,
allow_bot_chats,
allow_group_chats,
allow_channel_chats,
}
}
pub fn user_chats(query: impl Into<Option<String>>) -> Self {
Self {
query: query.into(),
allow_user_chats: true,
..Default::default()
}
}
pub fn bot_chats(query: impl Into<Option<String>>) -> Self {
Self {
query: query.into(),
allow_bot_chats: true,
..Default::default()
}
}
pub fn group_chats(query: impl Into<Option<String>>) -> Self {
Self {
query: query.into(),
allow_group_chats: true,
..Default::default()
}
}
pub fn channel_chats(query: impl Into<Option<String>>) -> Self {
Self {
query: query.into(),
allow_channel_chats: true,
..Default::default()
}
}
}