grammers_client/message/
reactions.rs1use grammers_tl_types::{self as tl, enums::Reaction};
10
11#[derive(Clone, Debug, Default)]
13pub struct InputReactions {
14 pub(crate) reactions: Vec<Reaction>,
15 pub(crate) add_to_recent: bool,
16 pub(crate) big: bool,
17}
18
19impl InputReactions {
20 pub fn big(mut self) -> Self {
22 self.big = true;
23 self
24 }
25
26 pub fn add_to_recent(mut self) -> Self {
30 self.add_to_recent = true;
31 self
32 }
33
34 pub fn emoticon<S: Into<String>>(emoticon: S) -> Self {
36 Self {
37 reactions: vec![Reaction::Emoji(tl::types::ReactionEmoji {
38 emoticon: emoticon.into(),
39 })],
40 ..Self::default()
41 }
42 }
43
44 pub fn custom_emoji(document_id: i64) -> Self {
46 Self {
47 reactions: vec![Reaction::CustomEmoji(tl::types::ReactionCustomEmoji {
48 document_id,
49 })],
50 ..Self::default()
51 }
52 }
53
54 pub fn remove() -> Self {
56 Self::default()
57 }
58}
59
60impl From<String> for InputReactions {
61 fn from(val: String) -> Self {
62 InputReactions::emoticon(val)
63 }
64}
65
66impl From<&str> for InputReactions {
67 fn from(val: &str) -> Self {
68 InputReactions::emoticon(val)
69 }
70}
71
72impl From<Vec<Reaction>> for InputReactions {
73 fn from(reactions: Vec<Reaction>) -> Self {
74 Self {
75 reactions,
76 ..Self::default()
77 }
78 }
79}
80
81impl From<InputReactions> for Vec<Reaction> {
82 fn from(val: InputReactions) -> Self {
83 val.reactions
84 }
85}