Skip to main content

telegram_rich/types/
common.rs

1//! Small shared objects referenced by rich message types.
2
3use serde::{Deserialize, Serialize};
4
5/// A Telegram user (subset of fields relevant to rich text mentions).
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7pub struct User {
8    /// Unique identifier for this user or bot.
9    pub id: i64,
10    /// True, if this user is a bot.
11    pub is_bot: bool,
12    /// User's or bot's first name.
13    pub first_name: String,
14    /// Optional. User's or bot's last name.
15    #[serde(default, skip_serializing_if = "Option::is_none")]
16    pub last_name: Option<String>,
17    /// Optional. User's or bot's username.
18    #[serde(default, skip_serializing_if = "Option::is_none")]
19    pub username: Option<String>,
20    /// Optional. IETF language tag of the user's language.
21    #[serde(default, skip_serializing_if = "Option::is_none")]
22    pub language_code: Option<String>,
23}
24
25/// A point on the map.
26#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
27pub struct Location {
28    /// Latitude.
29    pub latitude: f64,
30    /// Longitude.
31    pub longitude: f64,
32    /// Optional. The radius of uncertainty for the location, in meters; 0-1500.
33    #[serde(default, skip_serializing_if = "Option::is_none")]
34    pub horizontal_accuracy: Option<f64>,
35}
36
37/// Describes a Web App.
38#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
39pub struct WebAppInfo {
40    /// An HTTPS URL of a Web App.
41    pub url: String,
42}
43
44/// A parameter of a button used to automatically authorize a user.
45#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
46pub struct LoginUrl {
47    /// An HTTPS URL to be opened with user authorization data added to the query string.
48    pub url: String,
49    /// Optional. New text of the button in forwarded messages.
50    #[serde(default, skip_serializing_if = "Option::is_none")]
51    pub forward_text: Option<String>,
52    /// Optional. Username of a bot used for user authorization; not supported in rich message buttons.
53    #[serde(default, skip_serializing_if = "Option::is_none")]
54    pub bot_username: Option<String>,
55    /// Optional. Request the permission for the bot to send messages to the user.
56    #[serde(default, skip_serializing_if = "Option::is_none")]
57    pub request_write_access: Option<bool>,
58}
59
60/// An inline button that switches the user to inline mode in a chosen chat.
61#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
62pub struct SwitchInlineQueryChosenChat {
63    /// Optional. The default inline query.
64    #[serde(default, skip_serializing_if = "Option::is_none")]
65    pub query: Option<String>,
66    /// Optional. True, if private chats with users can be chosen.
67    #[serde(default, skip_serializing_if = "Option::is_none")]
68    pub allow_user_chats: Option<bool>,
69    /// Optional. True, if private chats with bots can be chosen.
70    #[serde(default, skip_serializing_if = "Option::is_none")]
71    pub allow_bot_chats: Option<bool>,
72    /// Optional. True, if group and supergroup chats can be chosen.
73    #[serde(default, skip_serializing_if = "Option::is_none")]
74    pub allow_group_chats: Option<bool>,
75    /// Optional. True, if channel chats can be chosen.
76    #[serde(default, skip_serializing_if = "Option::is_none")]
77    pub allow_channel_chats: Option<bool>,
78}
79
80/// A button that copies the specified text to the clipboard.
81#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
82pub struct CopyTextButton {
83    /// The text to be copied; 1-256 characters.
84    pub text: String,
85}
86
87/// A disabled button which does nothing. Currently holds no information.
88#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
89pub struct DisabledButton {}