telexide_fork/model/
message_entity.rs

1pub use super::utils::TextBlock;
2use super::User;
3use serde::{Deserialize, Serialize};
4
5/// This object represents one special entity in a text message.
6/// For example, hashtags, usernames, URLs, etc.
7#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
8#[serde(tag = "type")]
9pub enum MessageEntity {
10    /// A mention (`@username`)
11    #[serde(rename = "mention")]
12    Mention(TextBlock),
13    /// A hashtag (`#hashtag`)
14    #[serde(rename = "hashtag")]
15    HashTag(TextBlock),
16    /// A cashtag (`$USD`)
17    #[serde(rename = "cashtag")]
18    CashTag(TextBlock),
19    /// A bot command (`/start@bot_name`)
20    #[serde(rename = "bot_command")]
21    BotCommand(TextBlock),
22    /// An url (`https://telegram.org`)
23    #[serde(rename = "url")]
24    Url(TextBlock),
25    /// An email address (`do-not-reply@telegram.org`)
26    #[serde(rename = "email")]
27    Email(TextBlock),
28    /// A phone number (`+1-212-555-0123`)
29    #[serde(rename = "phone_number")]
30    PhoneNumber(TextBlock),
31    /// Bold text
32    #[serde(rename = "bold")]
33    Bold(TextBlock),
34    /// Italic text
35    #[serde(rename = "italic")]
36    Italic(TextBlock),
37    /// Underlined text
38    #[serde(rename = "underline")]
39    Underline(TextBlock),
40    /// strikethrough text
41    #[serde(rename = "strikethrough")]
42    StrikeThrough(TextBlock),
43    /// A monowidth code string
44    #[serde(rename = "code")]
45    Code(TextBlock),
46    /// a monowidth code block
47    #[serde(rename = "pre")]
48    Pre(Pre),
49    /// A clickable text URL
50    #[serde(rename = "text_link")]
51    TextLink(TextLink),
52    /// A mention of users without usernames
53    #[serde(rename = "text_mention")]
54    TextMention(TextMention),
55    /// Inline custom emoji stickers
56    #[serde(rename = "custom_emoji")]
57    CustomEmoji(InlineCustomEmoji),
58    /// A spoiler
59    #[serde(rename = "spoiler")]
60    Spoiler(TextBlock),
61    /// Blockquote
62    #[serde(rename = "blockquote")]
63    Blockquote(TextBlock),
64    /// Expandable Blockquote
65    #[serde(rename = "expandable_blockquote")]
66    ExpandableBlockquote(TextBlock),
67}
68
69/// A monowidth code block
70#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
71pub struct Pre {
72    /// The part of the text that is the code block
73    #[serde(flatten)]
74    pub text_block: TextBlock,
75    /// The programming language of the entity text
76    pub language: Option<String>,
77}
78
79/// A clickable text URL
80#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
81pub struct TextLink {
82    /// The part of the text that if clicked will open an url
83    #[serde(flatten)]
84    pub text_block: TextBlock,
85    /// The url that will be opened after user taps on the text
86    pub url: String,
87}
88
89/// For users [without usernames](https://telegram.org/blog/edit#new-mentions)
90#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
91pub struct TextMention {
92    /// The part of the text that is the mention
93    #[serde(flatten)]
94    pub text_block: TextBlock,
95    /// The mentioned user
96    pub user: User,
97}
98
99#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
100pub struct InlineCustomEmoji {
101    /// The part of the text that is the custom emoji
102    #[serde(flatten)]
103    pub text_block: TextBlock,
104    /// For “custom_emoji” only, unique identifier of the custom emoji. Use
105    /// [`get_custom_emoji_stickers`] to get full information about the sticker
106    ///
107    /// [`get_custom_emoji_stickers`]: ../../api/trait.API.html#method.get_custom_emoji_stickers
108    pub custom_emoji_id: String,
109}