1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
use super::InputMedia;
use crate::model::{InlineKeyboardMarkup, Message, MessageEntity, ParseMode};
use serde::{Deserialize, Serialize};

/// struct for holding data needed to call

/// [`edit_message_text`]

///

/// [`edit_message_text`]:

/// ../../api/trait.API.html#method.edit_message_text

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct EditMessageText {
    /// Unique identifier for the target chat

    #[serde(skip_serializing_if = "Option::is_none")]
    pub chat_id: Option<i64>,
    /// Identifier of the message to edit

    #[serde(skip_serializing_if = "Option::is_none")]
    pub message_id: Option<i64>,
    /// Identifier of the inline message

    #[serde(skip_serializing_if = "Option::is_none")]
    pub inline_message_id: Option<String>,
    /// New text of the message, 1-4096 characters after entities parsing

    pub text: String,
    /// Send Markdown or HTML, if you want Telegram apps to show bold, italic,

    /// fixed-width text or inline URLs in your bot's message.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub parse_mode: Option<ParseMode>,
    /// List of special entities that appear in message text, which can be

    /// specified instead of parse_mode

    #[serde(skip_serializing_if = "Option::is_none")]
    pub entities: Option<Vec<MessageEntity>>,
    /// Disables link previews for links in this message

    pub disable_web_page_preview: bool,
    /// Inline keyboard

    #[serde(skip_serializing_if = "Option::is_none")]
    pub reply_markup: Option<InlineKeyboardMarkup>,
}

impl EditMessageText {
    fn new(chat_id: i64, message_id: i64, new_text: &str) -> Self {
        Self {
            chat_id: Some(chat_id),
            message_id: Some(message_id),
            text: new_text.to_owned(),
            inline_message_id: None,
            parse_mode: None,
            entities: None,
            disable_web_page_preview: false,
            reply_markup: None,
        }
    }

    fn from_message(message: &Message, new_text: &str) -> Self {
        Self {
            chat_id: Some(message.chat.get_id()),
            message_id: Some(message.message_id),
            text: new_text.to_owned(),
            inline_message_id: None,
            parse_mode: None,
            entities: None,
            disable_web_page_preview: false,
            reply_markup: None,
        }
    }
}

/// struct for holding data needed to call

/// [`edit_message_caption`]

///

/// [`edit_message_caption`]:

/// ../../api/trait.API.html#method.edit_message_caption

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct EditMessageCaption {
    /// Unique identifier for the target chat

    #[serde(skip_serializing_if = "Option::is_none")]
    pub chat_id: Option<i64>,
    /// Identifier of the message to edit

    #[serde(skip_serializing_if = "Option::is_none")]
    pub message_id: Option<i64>,
    /// Identifier of the inline message

    #[serde(skip_serializing_if = "Option::is_none")]
    pub inline_message_id: Option<String>,
    /// New caption of the message, 0-1024 characters after entities parsing

    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption: Option<String>,
    /// Send Markdown or HTML, if you want Telegram apps to show bold, italic,

    /// fixed-width text or inline URLs in your bot's message.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub parse_mode: Option<ParseMode>,
    /// List of special entities that appear in the caption, which can be

    /// specified instead of parse_mode

    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption_entities: Option<Vec<MessageEntity>>,
    /// Inline keyboard

    #[serde(skip_serializing_if = "Option::is_none")]
    pub reply_markup: Option<InlineKeyboardMarkup>,
}

impl EditMessageCaption {
    fn new(chat_id: i64, message_id: i64, new_text: Option<&str>) -> Self {
        Self {
            chat_id: Some(chat_id),
            message_id: Some(message_id),
            caption: new_text.map(ToString::to_string),
            inline_message_id: None,
            parse_mode: None,
            caption_entities: None,
            reply_markup: None,
        }
    }

    fn from_message(message: &Message, new_text: Option<&str>) -> Self {
        Self {
            chat_id: Some(message.chat.get_id()),
            message_id: Some(message.message_id),
            caption: new_text.map(ToString::to_string),
            inline_message_id: None,
            parse_mode: None,
            caption_entities: None,
            reply_markup: None,
        }
    }
}

/// struct for holding data needed to call

/// [`edit_message_media`]

///

/// [`edit_message_media`]:

/// ../../api/trait.API.html#method.edit_message_media

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct EditMessageMedia {
    /// Unique identifier for the target chat

    #[serde(skip_serializing_if = "Option::is_none")]
    pub chat_id: Option<i64>,
    /// Identifier of the message to edit

    #[serde(skip_serializing_if = "Option::is_none")]
    pub message_id: Option<i64>,
    /// Identifier of the inline message

    #[serde(skip_serializing_if = "Option::is_none")]
    pub inline_message_id: Option<String>,
    /// new media content of the message

    pub media: InputMedia,
    /// Inline keyboard

    #[serde(skip_serializing_if = "Option::is_none")]
    pub reply_markup: Option<InlineKeyboardMarkup>,
}

impl EditMessageMedia {
    fn new(chat_id: i64, message_id: i64, new_media: &InputMedia) -> Self {
        Self {
            chat_id: Some(chat_id),
            message_id: Some(message_id),
            media: new_media.to_owned(),
            inline_message_id: None,
            reply_markup: None,
        }
    }

    fn from_message(message: &Message, new_media: &InputMedia) -> Self {
        Self {
            chat_id: Some(message.chat.get_id()),
            message_id: Some(message.message_id),
            media: new_media.to_owned(),
            inline_message_id: None,
            reply_markup: None,
        }
    }
}

/// struct for holding data needed to call

/// [`edit_message_reply_markup`]

///

/// [`edit_message_reply_markup`]:

/// ../../api/trait.API.html#method.edit_message_reply_markup

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct EditMessageReplyMarkup {
    /// Unique identifier for the target chat

    #[serde(skip_serializing_if = "Option::is_none")]
    pub chat_id: Option<i64>,
    /// Identifier of the message to edit

    #[serde(skip_serializing_if = "Option::is_none")]
    pub message_id: Option<i64>,
    /// Identifier of the inline message

    #[serde(skip_serializing_if = "Option::is_none")]
    pub inline_message_id: Option<String>,
    /// Inline keyboard

    #[serde(skip_serializing_if = "Option::is_none")]
    pub reply_markup: Option<InlineKeyboardMarkup>,
}

impl EditMessageReplyMarkup {
    fn new(chat_id: i64, message_id: i64, new_markup: Option<&InlineKeyboardMarkup>) -> Self {
        Self {
            chat_id: Some(chat_id),
            message_id: Some(message_id),
            inline_message_id: None,
            reply_markup: new_markup.cloned(),
        }
    }

    fn from_message(message: &Message, new_markup: Option<&InlineKeyboardMarkup>) -> Self {
        Self {
            chat_id: Some(message.chat.get_id()),
            message_id: Some(message.message_id),
            inline_message_id: None,
            reply_markup: new_markup.cloned(),
        }
    }
}

/// struct for holding data needed to call

/// [`stop_poll`]

///

/// [`stop_poll`]:

/// ../../api/trait.API.html#method.stop_poll

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct StopPoll {
    /// Unique identifier for the target chat

    pub chat_id: i64,
    /// Identifier of the message to edit

    pub message_id: i64,
    /// Inline keyboard

    #[serde(skip_serializing_if = "Option::is_none")]
    pub reply_markup: Option<InlineKeyboardMarkup>,
}

impl StopPoll {
    fn new(chat_id: i64, message_id: i64) -> Self {
        Self {
            chat_id,
            message_id,
            reply_markup: None,
        }
    }

    fn from_message(message: &Message) -> Self {
        Self {
            chat_id: message.chat.get_id(),
            message_id: message.message_id,
            reply_markup: None,
        }
    }
}

/// struct for holding data needed to call

/// [`delete_message`]

///

/// [`delete_message`]:

/// ../../api/trait.API.html#method.delete_message

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct DeleteMessage {
    /// Unique identifier for the target chat

    pub chat_id: i64,
    /// Identifier of the message to delete

    pub message_id: i64,
}

impl DeleteMessage {
    fn new(chat_id: i64, message_id: i64) -> Self {
        Self {
            chat_id,
            message_id,
        }
    }

    fn from_message(message: &Message) -> Self {
        Self {
            chat_id: message.chat.get_id(),
            message_id: message.message_id,
        }
    }
}

/// struct for holding data needed to call

/// [`edit_message_live_location`]

///

/// [`edit_message_live_location`]:

/// ../../api/trait.API.html#method.edit_message_live_location

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct EditMessageLiveLocation {
    /// Unique identifier for the target chat

    #[serde(skip_serializing_if = "Option::is_none")]
    pub chat_id: Option<i64>,
    /// Identifier of the message to edit

    #[serde(skip_serializing_if = "Option::is_none")]
    pub message_id: Option<i64>,
    /// Identifier of the inline message

    #[serde(skip_serializing_if = "Option::is_none")]
    pub inline_message_id: Option<String>,
    /// Inline keyboard

    #[serde(skip_serializing_if = "Option::is_none")]
    pub reply_markup: Option<InlineKeyboardMarkup>,
    /// Latitude of the location

    pub latitude: f64,
    /// Longitude of the location

    pub longitude: f64,
    /// The radius of uncertainty for the location, measured in meters; 0-1500

    #[serde(skip_serializing_if = "Option::is_none")]
    pub horizontal_accuracy: Option<f64>,
    /// Direction in which the user is moving, in degrees. Must be between 1 and

    /// 360 if specified.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub heading: Option<i64>,
    /// Maximum distance for proximity alerts about approaching another chat

    /// member, in meters. Must be between 1 and 100000 if specified.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub proximity_alert_radius: Option<i64>,
}

/// struct for holding data needed to call

/// [`stop_message_live_location`]

///

/// [`stop_message_live_location`]:

/// ../../api/trait.API.html#method.edit_message_live_location

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct StopMessageLiveLocation {
    /// Unique identifier for the target chat

    #[serde(skip_serializing_if = "Option::is_none")]
    pub chat_id: Option<i64>,
    /// Identifier of the message to stop

    #[serde(skip_serializing_if = "Option::is_none")]
    pub message_id: Option<i64>,
    /// Identifier of the inline message

    #[serde(skip_serializing_if = "Option::is_none")]
    pub inline_message_id: Option<String>,
    /// Inline keyboard

    #[serde(skip_serializing_if = "Option::is_none")]
    pub reply_markup: Option<InlineKeyboardMarkup>,
}