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
use std::{
future::{Future, IntoFuture},
pin::Pin,
};
use serde::Serialize;
use crate::{
api::API,
entities::{
file::File,
misc::input_file::{GetFiles, InputFile},
},
errors::ConogramError,
impl_into_future_multipart,
request::RequestT,
};
#[derive(Debug, Clone, Serialize)]
pub struct UploadStickerFileParams {
pub user_id: i64,
pub sticker: InputFile,
pub sticker_format: UploadStickerFileStickerFormat,
}
impl GetFiles for UploadStickerFileParams {
fn get_files(&self) -> Vec<&InputFile> {
vec![&self.sticker]
}
}
impl_into_future_multipart!(UploadStickerFileRequest<'a>);
///Use this method to upload a file with a sticker for later use in the [createNewStickerSet](https://core.telegram.org/bots/api/#createnewstickerset), [addStickerToSet](https://core.telegram.org/bots/api/#addstickertoset), or [replaceStickerInSet](https://core.telegram.org/bots/api/#replacestickerinset) methods (the file can be used multiple times). Returns the uploaded [File](https://core.telegram.org/bots/api/#file) on success.
#[derive(Clone)]
pub struct UploadStickerFileRequest<'a> {
api: &'a API,
params: UploadStickerFileParams,
}
impl<'a> RequestT for UploadStickerFileRequest<'a> {
type ParamsType = UploadStickerFileParams;
type ReturnType = File;
fn get_name() -> &'static str {
"uploadStickerFile"
}
fn get_api_ref(&self) -> &API {
self.api
}
fn get_params_ref(&self) -> &Self::ParamsType {
&self.params
}
fn is_multipart() -> bool {
true
}
}
impl<'a> UploadStickerFileRequest<'a> {
pub fn new(
api: &'a API,
user_id: impl Into<i64>,
sticker: impl Into<InputFile>,
sticker_format: impl Into<UploadStickerFileStickerFormat>,
) -> Self {
Self {
api,
params: UploadStickerFileParams {
user_id: user_id.into(),
sticker: sticker.into(),
sticker_format: sticker_format.into(),
},
}
}
///User identifier of sticker file owner
#[must_use]
pub fn user_id(mut self, user_id: impl Into<i64>) -> Self {
self.params.user_id = user_id.into();
self
}
///A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See [https://core.telegram.org/stickers](https://core.telegram.org/stickers) for technical requirements. [More information on Sending Files »](https://core.telegram.org/bots/api/#sending-files)
#[must_use]
pub fn sticker(mut self, sticker: impl Into<InputFile>) -> Self {
self.params.sticker = sticker.into();
self
}
///Format of the sticker, must be one of “static”, “animated”, “video”
#[must_use]
pub fn sticker_format(
mut self,
sticker_format: impl Into<UploadStickerFileStickerFormat>,
) -> Self {
self.params.sticker_format = sticker_format.into();
self
}
}
impl API {
///Use this method to upload a file with a sticker for later use in the [createNewStickerSet](https://core.telegram.org/bots/api/#createnewstickerset), [addStickerToSet](https://core.telegram.org/bots/api/#addstickertoset), or [replaceStickerInSet](https://core.telegram.org/bots/api/#replacestickerinset) methods (the file can be used multiple times). Returns the uploaded [File](https://core.telegram.org/bots/api/#file) on success.
pub fn upload_sticker_file(
&self,
user_id: impl Into<i64>,
sticker: impl Into<InputFile>,
sticker_format: impl Into<UploadStickerFileStickerFormat>,
) -> UploadStickerFileRequest {
UploadStickerFileRequest::new(self, user_id, sticker, sticker_format)
}
}
///Format of the sticker, must be one of “static”, “animated”, “video”
#[derive(Debug, Clone, Default, PartialEq, Serialize)]
#[serde(rename = "sticker_format")]
pub enum UploadStickerFileStickerFormat {
#[default]
/// "static"
#[serde(rename = "static")]
Static,
/// "animated"
#[serde(rename = "animated")]
Animated,
/// "video"
#[serde(rename = "video")]
Video,
}
// Divider: all content below this line will be preserved after code regen