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
// WARNING: THIS CODE IS AUTOGENERATED.
// DO NOT EDIT!!!
#![allow(clippy::too_many_arguments)]
use serde::Serialize;
use crate::error::Result;
use crate::types::InputSticker;
use crate::Bot;
impl Bot {
/// Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success.
/// <https://core.telegram.org/bots/api#createnewstickerset>
pub fn create_new_sticker_set(
&self,
user_id: i64,
name: String,
title: String,
stickers: Vec<InputSticker>,
) -> CreateNewStickerSetBuilder {
CreateNewStickerSetBuilder::new(self, user_id, name, title, stickers)
}
}
#[derive(Serialize)]
pub struct CreateNewStickerSetBuilder<'a> {
#[serde(skip)]
bot: &'a Bot,
/// User identifier of created sticker set owner
pub user_id: i64,
/// Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "_by_<bot_username>". <bot_username> is case insensitive. 1-64 characters.
pub name: String,
/// Sticker set title, 1-64 characters
pub title: String,
/// A JSON-serialized list of 1-50 initial stickers to be added to the sticker set
pub stickers: Vec<InputSticker>,
/// Type of stickers in the set, pass "regular", "mask", or "custom_emoji". By default, a regular sticker set is created.
#[serde(skip_serializing_if = "Option::is_none")]
pub sticker_type: Option<String>,
/// Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only
#[serde(skip_serializing_if = "Option::is_none")]
pub needs_repainting: Option<bool>,
}
impl<'a> CreateNewStickerSetBuilder<'a> {
pub fn new(
bot: &'a Bot,
user_id: i64,
name: String,
title: String,
stickers: Vec<InputSticker>,
) -> Self {
Self {
bot,
user_id,
name,
title,
stickers,
sticker_type: None,
needs_repainting: None,
}
}
pub fn user_id(mut self, user_id: i64) -> Self {
self.user_id = user_id;
self
}
pub fn name(mut self, name: String) -> Self {
self.name = name;
self
}
pub fn title(mut self, title: String) -> Self {
self.title = title;
self
}
pub fn stickers(mut self, stickers: Vec<InputSticker>) -> Self {
self.stickers = stickers;
self
}
pub fn sticker_type(mut self, sticker_type: String) -> Self {
self.sticker_type = Some(sticker_type);
self
}
pub fn needs_repainting(mut self, needs_repainting: bool) -> Self {
self.needs_repainting = Some(needs_repainting);
self
}
pub async fn send(self) -> Result<bool> {
let form = serde_json::to_value(&self)?;
self.bot.get("createNewStickerSet", Some(&form)).await
}
}