telers/methods/
set_game_score.rs1use super::base::{Request, TelegramMethod};
2
3use crate::{client::Bot, types::MessageOrTrue};
4
5use serde::Serialize;
6use serde_with::skip_serializing_none;
7
8#[skip_serializing_none]
14#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize)]
15pub struct SetGameScore {
16 pub user_id: i64,
18 pub score: u64,
20 pub force: Option<bool>,
22 pub disable_edit_message: Option<bool>,
24 pub chat_id: Option<i64>,
26 pub message_id: Option<i64>,
28 pub inline_message_id: Option<String>,
30}
31
32impl SetGameScore {
33 #[must_use]
34 pub fn new(user_id: i64, score: u64) -> Self {
35 Self {
36 user_id,
37 score,
38 force: None,
39 disable_edit_message: None,
40 chat_id: None,
41 message_id: None,
42 inline_message_id: None,
43 }
44 }
45
46 #[must_use]
47 pub fn user_id(self, val: i64) -> Self {
48 Self {
49 user_id: val,
50 ..self
51 }
52 }
53
54 #[must_use]
55 pub fn score(self, val: u64) -> Self {
56 Self { score: val, ..self }
57 }
58
59 #[must_use]
60 pub fn force(self, val: bool) -> Self {
61 Self {
62 force: Some(val),
63 ..self
64 }
65 }
66
67 #[must_use]
68 pub fn disable_edit_message(self, val: bool) -> Self {
69 Self {
70 disable_edit_message: Some(val),
71 ..self
72 }
73 }
74
75 #[must_use]
76 pub fn chat_id(self, val: i64) -> Self {
77 Self {
78 chat_id: Some(val),
79 ..self
80 }
81 }
82
83 #[must_use]
84 pub fn message_id(self, val: i64) -> Self {
85 Self {
86 message_id: Some(val),
87 ..self
88 }
89 }
90
91 #[must_use]
92 pub fn inline_message_id(self, val: impl Into<String>) -> Self {
93 Self {
94 inline_message_id: Some(val.into()),
95 ..self
96 }
97 }
98}
99
100impl SetGameScore {
101 #[must_use]
102 pub fn force_option(self, val: Option<bool>) -> Self {
103 Self { force: val, ..self }
104 }
105
106 #[must_use]
107 pub fn disable_edit_message_option(self, val: Option<bool>) -> Self {
108 Self {
109 disable_edit_message: val,
110 ..self
111 }
112 }
113
114 #[must_use]
115 pub fn chat_id_option(self, val: Option<i64>) -> Self {
116 Self {
117 chat_id: val,
118 ..self
119 }
120 }
121
122 #[must_use]
123 pub fn message_id_option(self, val: Option<i64>) -> Self {
124 Self {
125 message_id: val,
126 ..self
127 }
128 }
129
130 #[must_use]
131 pub fn inline_message_id_option(self, val: Option<impl Into<String>>) -> Self {
132 Self {
133 inline_message_id: val.map(Into::into),
134 ..self
135 }
136 }
137}
138
139impl TelegramMethod for SetGameScore {
140 type Method = Self;
141 type Return = MessageOrTrue;
142
143 fn build_request<Client>(&self, _bot: &Bot<Client>) -> Request<Self::Method> {
144 Request::new("setGameScore", self, None)
145 }
146}
147
148impl AsRef<SetGameScore> for SetGameScore {
149 fn as_ref(&self) -> &Self {
150 self
151 }
152}