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
use crate::client::Bot;
use serde::Serialize;
/// Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns `true` on success.
/// # Documentation
/// <https://core.telegram.org/bots/api#setstickerkeywords>
/// # Returns
/// - `bool`
#[derive(Clone, Debug, Serialize)]
pub struct SetStickerKeywords {
/// File identifier of the sticker
pub sticker: Box<str>,
/// A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters
#[serde(skip_serializing_if = "Option::is_none")]
pub keywords: Option<Box<[Box<str>]>>,
}
impl SetStickerKeywords {
/// Creates a new `SetStickerKeywords`.
///
/// # Arguments
/// * `sticker` - File identifier of the sticker
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<T0: Into<Box<str>>>(sticker: T0) -> Self {
Self {
sticker: sticker.into(),
keywords: None,
}
}
/// File identifier of the sticker
#[must_use]
pub fn sticker<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.sticker = val.into();
this
}
/// A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters
///
/// # Notes
/// Adds multiple elements.
#[must_use]
pub fn keywords<TItem: Into<Box<str>>, T: IntoIterator<Item = TItem>>(self, val: T) -> Self {
let mut this = self;
this.keywords = Some(
this.keywords
.unwrap_or_default()
.into_vec()
.into_iter()
.chain(val.into_iter().map(Into::into))
.collect(),
);
this
}
/// A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters
///
/// # Notes
/// Adds a single element.
#[must_use]
pub fn keyword<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.keywords = Some(
this.keywords
.unwrap_or_default()
.into_vec()
.into_iter()
.chain(Some(val.into()))
.collect(),
);
this
}
/// A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters
///
/// # Notes
/// Adds multiple elements.
#[must_use]
pub fn keywords_option<TItem: Into<Box<str>>, T: IntoIterator<Item = TItem>>(
self,
val: Option<T>,
) -> Self {
let mut this = self;
this.keywords = val.map(|v| v.into_iter().map(Into::into).collect());
this
}
}
impl super::TelegramMethod for SetStickerKeywords {
type Method = Self;
type Return = bool;
fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
super::Request::new("setStickerKeywords", self, None)
}
}