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
use serde::{Deserialize, Serialize};
use crate::{
entities::{file::File, mask_position::MaskPosition, photo_size::PhotoSize},
utils::deserialize_utils::is_false,
};
/// This object represents a sticker.
///
/// API Reference: [link](https://core.telegram.org/bots/api/#sticker)
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct Sticker {
/// Identifier for this file, which can be used to download or reuse the file
pub file_id: String,
/// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
pub file_unique_id: String,
/// Type of the sticker, currently one of “regular”, “mask”, “custom\_emoji”. The type of the sticker is independent from its format, which is determined by the fields *is\_animated* and *is\_video*.
#[serde(rename = "type")]
pub type_: StickerType,
/// Sticker width
pub width: i64,
/// Sticker height
pub height: i64,
/// *True*, if the sticker is [animated](https://telegram.org/blog/animated-stickers)
pub is_animated: bool,
/// *True*, if the sticker is a [video sticker](https://telegram.org/blog/video-stickers-better-reactions)
pub is_video: bool,
/// *Optional*. Sticker thumbnail in the .WEBP or .JPG format
#[serde(default, skip_serializing_if = "Option::is_none")]
pub thumbnail: Option<PhotoSize>,
/// *Optional*. Emoji associated with the sticker
#[serde(default, skip_serializing_if = "Option::is_none")]
pub emoji: Option<String>,
/// *Optional*. Name of the sticker set to which the sticker belongs
#[serde(default, skip_serializing_if = "Option::is_none")]
pub set_name: Option<String>,
/// *Optional*. For premium regular stickers, premium animation for the sticker
#[serde(default, skip_serializing_if = "Option::is_none")]
pub premium_animation: Option<File>,
/// *Optional*. For mask stickers, the position where the mask should be placed
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mask_position: Option<MaskPosition>,
/// *Optional*. For custom emoji stickers, unique identifier of the custom emoji
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_emoji_id: Option<String>,
/// *Optional*. *True*, if the sticker must be repainted to a text color in messages, the color of the Telegram Premium badge in emoji status, white color on chat photos, or another appropriate color in other places
#[serde(default, skip_serializing_if = "is_false")]
pub needs_repainting: bool,
/// *Optional*. File size in bytes
#[serde(default, skip_serializing_if = "Option::is_none")]
pub file_size: Option<i64>,
}
/// Type of the sticker, currently one of “regular”, “mask”, “custom\_emoji”. The type of the sticker is independent from its format, which is determined by the fields *is\_animated* and *is\_video*.
#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)]
pub enum StickerType {
/// `regular`
#[default]
#[serde(rename = "regular")]
Regular,
/// `mask`
#[serde(rename = "mask")]
Mask,
/// `custom_emoji`
#[serde(rename = "custom_emoji")]
CustomEmoji,
}
// Divider: all content below this line will be preserved after code regen
use crate::{api::API, methods::get_sticker_set::GetStickerSetRequest};
impl Sticker {
/// Returns a [GetStickerSetRequest] if the sticker has a set, e.g. ([Sticker.set_name](Self::set_name) is `Some`)
pub fn get_sticker_set<'a>(&self, api: &'a API) -> Option<GetStickerSetRequest<'a>> {
self.set_name
.as_ref()
.map(|set_name| api.get_sticker_set(set_name))
}
}