use layer_tl_types::{self as tl, enums::Reaction};
#[derive(Clone, Debug, Default)]
pub struct InputReactions {
pub(crate) reactions: Vec<Reaction>,
pub(crate) add_to_recent: bool,
pub(crate) big: bool,
}
impl InputReactions {
pub fn emoticon<S: Into<String>>(emoticon: S) -> Self {
Self {
reactions: vec![Reaction::Emoji(tl::types::ReactionEmoji {
emoticon: emoticon.into(),
})],
..Self::default()
}
}
pub fn custom_emoji(document_id: i64) -> Self {
Self {
reactions: vec![Reaction::CustomEmoji(tl::types::ReactionCustomEmoji {
document_id,
})],
..Self::default()
}
}
pub fn remove() -> Self {
Self::default()
}
pub fn big(mut self) -> Self {
self.big = true;
self
}
pub fn add_to_recent(mut self) -> Self {
self.add_to_recent = true;
self
}
}
impl From<&str> for InputReactions {
fn from(s: &str) -> Self {
InputReactions::emoticon(s)
}
}
impl From<String> for InputReactions {
fn from(s: String) -> Self {
InputReactions::emoticon(s)
}
}
impl From<Vec<Reaction>> for InputReactions {
fn from(reactions: Vec<Reaction>) -> Self {
Self {
reactions,
..Self::default()
}
}
}
impl From<InputReactions> for Vec<Reaction> {
fn from(r: InputReactions) -> Self {
r.reactions
}
}