telexide_fork/model/other.rs
1use super::{
2 utils::unix_date_formatting, ForceReply, InlineKeyboardMarkup, Message, ReplyKeyboardMarkup,
3 ReplyKeyboardRemove, User,
4};
5use crate::api::types::UpdateType;
6use chrono::{DateTime, Utc};
7use serde::{Deserialize, Serialize};
8
9/// This object represents an incoming callback query from a callback button in
10/// an [inline keyboard][kb]. If the button that originated the query was
11/// attached to a message sent by the bot, the field message will be present. If
12/// the button was attached to a message sent via the bot (in [inline
13/// mode][inline]), the field `inline_message_id` will be present. Exactly one
14/// of the fields data or `game_short_name` will be present.
15///
16/// [kb]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
17/// [inline]: https://core.telegram.org/bots/api#inline-mode
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
19pub struct CallbackQuery {
20 /// Unique identifier for this query
21 pub id: String,
22 /// Sender
23 pub from: User,
24 /// Message with the callback button that originated the query.
25 /// Note that message content and message date will not be available if the
26 /// message is too old
27 pub message: Option<Message>,
28 /// Identifier of the message sent via the bot in inline mode, that
29 /// originated the query.
30 pub inline_message_id: Option<Message>,
31 /// Global identifier, uniquely corresponding to the chat to which the
32 /// message with the callback button was sent. Useful for high scores in [games](https://core.telegram.org/bots/api#games).
33 pub chat_instance: String,
34 /// Data associated with the callback button. Be aware that a bad client can
35 /// send arbitrary data in this field.
36 pub data: Option<String>,
37 /// Short name of a [`Game`] to be returned, serves as the unique identifier
38 /// for the game
39 ///
40 /// [`Game`]: ../model/struct.Game.html
41 pub game_short_name: Option<String>,
42}
43
44/// A bot command
45#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
46pub struct BotCommand {
47 /// the command name, for example "ping" for the command "/ping"
48 pub command: String,
49 /// the description of the command to display in telegram
50 pub description: String,
51}
52
53/// The Bot API supports basic formatting for messages.
54/// You can use bold, italic, underlined and strikethrough text, as well as
55/// inline links and pre-formatted code in your bots' messages. Telegram clients
56/// will render them accordingly. You can use either markdown-style or
57/// HTML-style formatting.
58///
59/// note: `Markdown` only exists for backwards-compatibility reasons, please use
60/// `MarkdownV2`
61#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
62pub enum ParseMode {
63 MarkdownV2,
64 Markdown,
65 HTML,
66}
67
68/// An action indicating to a user what they are about to receive
69#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
70pub enum ChatAction {
71 /// for a text message
72 #[serde(rename = "typing")]
73 Typing,
74 /// for a photo
75 #[serde(rename = "upload_photo")]
76 UploadPhoto,
77 /// for a video
78 #[serde(rename = "record_video")]
79 RecordVideo,
80 /// for a video
81 #[serde(rename = "upload_video")]
82 UploadVideo,
83 /// for an audio file
84 #[serde(rename = "record_voice")]
85 RecordVoice,
86 /// for an audio file
87 #[serde(rename = "upload_voice")]
88 UploadVoice,
89 /// for a general file
90 #[serde(rename = "upload_document")]
91 UploadDocument,
92 /// for a location
93 #[serde(rename = "find_location")]
94 FindLocation,
95 /// for a video note
96 #[serde(rename = "record_video_note")]
97 RecordVideoNote,
98 /// for a video note
99 #[serde(rename = "upload_video_note")]
100 UploadVideoNote,
101}
102
103/// Enum object for an inline keyboard, custom reply keyboard, instructions to
104/// remove reply keyboard or to force a reply from the user.
105#[allow(clippy::large_enum_variant)]
106#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
107#[serde(untagged)]
108pub enum ReplyMarkup {
109 InlineKeyboardMarkup(InlineKeyboardMarkup),
110 ReplyKeyboardMarkup(ReplyKeyboardMarkup),
111 ReplyKeyboardRemove(ReplyKeyboardRemove),
112 ForceReply(ForceReply),
113}
114
115/// This object represents a file ready to be downloaded.
116/// The file can be downloaded via the link `https://api.telegram.org/file/bot<token>/<file_path>`.
117/// It is guaranteed that the link will be valid for at least 1 hour.
118/// When the link expires, a new one can be requested by calling [`get_file`].
119///
120/// **Note:** The maximum file size to download is 20 MB
121///
122/// [`get_file`]: ../api/trait.API.html#method.get_file
123#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
124pub struct File {
125 /// Identifier for this file, which can be used to download or reuse the
126 /// file
127 pub file_id: String,
128 /// Unique identifier for this file, which is supposed to be the same over
129 /// time and for different bots. Can't be used to download or reuse the
130 /// file.
131 pub file_unique_id: String,
132 /// File size, if known
133 pub file_size: Option<i64>,
134 /// File path. Use `https://api.telegram.org/file/bot<token>/<file_path>` to get the file.
135 /// It is guaranteed that the link will be valid for at least 1 hour. When
136 /// the link expires, a new one can be requested by calling getFile
137 /// again.
138 pub file_path: Option<String>,
139}
140
141/// Contains information about the current status of a webhook.
142#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
143pub struct WebhookInfo {
144 /// Webhook URL, may be empty if webhook is not set up
145 pub url: String,
146 /// True, if a custom certificate was provided for webhook certificate
147 /// checks
148 pub has_custom_certificate: bool,
149 /// Number of updates awaiting delivery
150 pub pending_update_count: i64,
151 /// Unix time for the most recent error that happened when trying to deliver
152 /// an update via webhook
153 #[serde(with = "unix_date_formatting::optional")]
154 pub last_error_date: Option<DateTime<Utc>>,
155 /// Error message in human-readable format for the most recent error that
156 /// happened when trying to deliver an update via webhook
157 pub last_error_message: Option<String>,
158 /// Maximum allowed number of simultaneous HTTPS connections to the webhook
159 /// for update delivery
160 pub max_connections: Option<i64>,
161 /// A list of update types the bot is subscribed to. Defaults to all update
162 /// types
163 pub allowed_updates: Option<Vec<UpdateType>>,
164 /// Currently used webhook IP address
165 pub ip_address: Option<String>,
166}