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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
use crate::client::Bot;
use serde::Serialize;
/// Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass `false` for all boolean parameters to demote a user. Returns `true` on success.
/// # Documentation
/// <https://core.telegram.org/bots/api#promotechatmember>
/// # Returns
/// - `bool`
#[derive(Clone, Debug, Serialize)]
pub struct PromoteChatMember {
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
pub chat_id: crate::types::ChatIdKind,
/// Unique identifier of the target user
pub user_id: i64,
/// Pass `true` if the administrator's presence in the chat is hidden
#[serde(skip_serializing_if = "Option::is_none")]
pub is_anonymous: Option<bool>,
/// Pass `true` if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_chat: Option<bool>,
/// Pass `true` if the administrator can delete messages of other users
#[serde(skip_serializing_if = "Option::is_none")]
pub can_delete_messages: Option<bool>,
/// Pass `true` if the administrator can manage video chats
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_video_chats: Option<bool>,
/// Pass `true` if the administrator can restrict, ban or unban chat members, or access supergroup statistics. For backward compatibility, defaults to `true` for promotions of channel administrators
#[serde(skip_serializing_if = "Option::is_none")]
pub can_restrict_members: Option<bool>,
/// Pass `true` if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by him)
#[serde(skip_serializing_if = "Option::is_none")]
pub can_promote_members: Option<bool>,
/// Pass `true` if the administrator can change chat title, photo and other settings
#[serde(skip_serializing_if = "Option::is_none")]
pub can_change_info: Option<bool>,
/// Pass `true` if the administrator can invite new users to the chat
#[serde(skip_serializing_if = "Option::is_none")]
pub can_invite_users: Option<bool>,
/// Pass `true` if the administrator can post stories to the chat
#[serde(skip_serializing_if = "Option::is_none")]
pub can_post_stories: Option<bool>,
/// Pass `true` if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive
#[serde(skip_serializing_if = "Option::is_none")]
pub can_edit_stories: Option<bool>,
/// Pass `true` if the administrator can delete stories posted by other users
#[serde(skip_serializing_if = "Option::is_none")]
pub can_delete_stories: Option<bool>,
/// Pass `true` if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only
#[serde(skip_serializing_if = "Option::is_none")]
pub can_post_messages: Option<bool>,
/// Pass `true` if the administrator can edit messages of other users and can pin messages; for channels only
#[serde(skip_serializing_if = "Option::is_none")]
pub can_edit_messages: Option<bool>,
/// Pass `true` if the administrator can pin messages; for supergroups only
#[serde(skip_serializing_if = "Option::is_none")]
pub can_pin_messages: Option<bool>,
/// Pass `true` if the user is allowed to create, rename, [`crate::methods::Close`], and reopen forum topics; for supergroups only
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_topics: Option<bool>,
/// Pass `true` if the administrator can manage direct messages within the channel and decline suggested posts; for channels only
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_direct_messages: Option<bool>,
/// Pass `true` if the administrator can edit the tags of regular members; for groups and supergroups only
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_tags: Option<bool>,
}
impl PromoteChatMember {
/// Creates a new `PromoteChatMember`.
///
/// # Arguments
/// * `chat_id` - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
/// * `user_id` - Unique identifier of the target user
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<T0: Into<crate::types::ChatIdKind>, T1: Into<i64>>(
chat_id: T0,
user_id: T1,
) -> Self {
Self {
chat_id: chat_id.into(),
user_id: user_id.into(),
is_anonymous: None,
can_manage_chat: None,
can_delete_messages: None,
can_manage_video_chats: None,
can_restrict_members: None,
can_promote_members: None,
can_change_info: None,
can_invite_users: None,
can_post_stories: None,
can_edit_stories: None,
can_delete_stories: None,
can_post_messages: None,
can_edit_messages: None,
can_pin_messages: None,
can_manage_topics: None,
can_manage_direct_messages: None,
can_manage_tags: None,
}
}
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
#[must_use]
pub fn chat_id<T: Into<crate::types::ChatIdKind>>(self, val: T) -> Self {
let mut this = self;
this.chat_id = val.into();
this
}
/// Unique identifier of the target user
#[must_use]
pub fn user_id<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.user_id = val.into();
this
}
/// Pass `true` if the administrator's presence in the chat is hidden
#[must_use]
pub fn is_anonymous<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.is_anonymous = Some(val.into());
this
}
/// Pass `true` if the administrator's presence in the chat is hidden
#[must_use]
pub fn is_anonymous_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.is_anonymous = val.map(Into::into);
this
}
/// Pass `true` if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege.
#[must_use]
pub fn can_manage_chat<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_manage_chat = Some(val.into());
this
}
/// Pass `true` if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege.
#[must_use]
pub fn can_manage_chat_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_manage_chat = val.map(Into::into);
this
}
/// Pass `true` if the administrator can delete messages of other users
#[must_use]
pub fn can_delete_messages<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_delete_messages = Some(val.into());
this
}
/// Pass `true` if the administrator can delete messages of other users
#[must_use]
pub fn can_delete_messages_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_delete_messages = val.map(Into::into);
this
}
/// Pass `true` if the administrator can manage video chats
#[must_use]
pub fn can_manage_video_chats<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_manage_video_chats = Some(val.into());
this
}
/// Pass `true` if the administrator can manage video chats
#[must_use]
pub fn can_manage_video_chats_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_manage_video_chats = val.map(Into::into);
this
}
/// Pass `true` if the administrator can restrict, ban or unban chat members, or access supergroup statistics. For backward compatibility, defaults to `true` for promotions of channel administrators
#[must_use]
pub fn can_restrict_members<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_restrict_members = Some(val.into());
this
}
/// Pass `true` if the administrator can restrict, ban or unban chat members, or access supergroup statistics. For backward compatibility, defaults to `true` for promotions of channel administrators
#[must_use]
pub fn can_restrict_members_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_restrict_members = val.map(Into::into);
this
}
/// Pass `true` if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by him)
#[must_use]
pub fn can_promote_members<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_promote_members = Some(val.into());
this
}
/// Pass `true` if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by him)
#[must_use]
pub fn can_promote_members_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_promote_members = val.map(Into::into);
this
}
/// Pass `true` if the administrator can change chat title, photo and other settings
#[must_use]
pub fn can_change_info<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_change_info = Some(val.into());
this
}
/// Pass `true` if the administrator can change chat title, photo and other settings
#[must_use]
pub fn can_change_info_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_change_info = val.map(Into::into);
this
}
/// Pass `true` if the administrator can invite new users to the chat
#[must_use]
pub fn can_invite_users<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_invite_users = Some(val.into());
this
}
/// Pass `true` if the administrator can invite new users to the chat
#[must_use]
pub fn can_invite_users_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_invite_users = val.map(Into::into);
this
}
/// Pass `true` if the administrator can post stories to the chat
#[must_use]
pub fn can_post_stories<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_post_stories = Some(val.into());
this
}
/// Pass `true` if the administrator can post stories to the chat
#[must_use]
pub fn can_post_stories_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_post_stories = val.map(Into::into);
this
}
/// Pass `true` if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive
#[must_use]
pub fn can_edit_stories<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_edit_stories = Some(val.into());
this
}
/// Pass `true` if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive
#[must_use]
pub fn can_edit_stories_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_edit_stories = val.map(Into::into);
this
}
/// Pass `true` if the administrator can delete stories posted by other users
#[must_use]
pub fn can_delete_stories<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_delete_stories = Some(val.into());
this
}
/// Pass `true` if the administrator can delete stories posted by other users
#[must_use]
pub fn can_delete_stories_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_delete_stories = val.map(Into::into);
this
}
/// Pass `true` if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only
#[must_use]
pub fn can_post_messages<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_post_messages = Some(val.into());
this
}
/// Pass `true` if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only
#[must_use]
pub fn can_post_messages_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_post_messages = val.map(Into::into);
this
}
/// Pass `true` if the administrator can edit messages of other users and can pin messages; for channels only
#[must_use]
pub fn can_edit_messages<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_edit_messages = Some(val.into());
this
}
/// Pass `true` if the administrator can edit messages of other users and can pin messages; for channels only
#[must_use]
pub fn can_edit_messages_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_edit_messages = val.map(Into::into);
this
}
/// Pass `true` if the administrator can pin messages; for supergroups only
#[must_use]
pub fn can_pin_messages<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_pin_messages = Some(val.into());
this
}
/// Pass `true` if the administrator can pin messages; for supergroups only
#[must_use]
pub fn can_pin_messages_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_pin_messages = val.map(Into::into);
this
}
/// Pass `true` if the user is allowed to create, rename, [`crate::methods::Close`], and reopen forum topics; for supergroups only
#[must_use]
pub fn can_manage_topics<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_manage_topics = Some(val.into());
this
}
/// Pass `true` if the user is allowed to create, rename, [`crate::methods::Close`], and reopen forum topics; for supergroups only
#[must_use]
pub fn can_manage_topics_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_manage_topics = val.map(Into::into);
this
}
/// Pass `true` if the administrator can manage direct messages within the channel and decline suggested posts; for channels only
#[must_use]
pub fn can_manage_direct_messages<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_manage_direct_messages = Some(val.into());
this
}
/// Pass `true` if the administrator can manage direct messages within the channel and decline suggested posts; for channels only
#[must_use]
pub fn can_manage_direct_messages_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_manage_direct_messages = val.map(Into::into);
this
}
/// Pass `true` if the administrator can edit the tags of regular members; for groups and supergroups only
#[must_use]
pub fn can_manage_tags<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_manage_tags = Some(val.into());
this
}
/// Pass `true` if the administrator can edit the tags of regular members; for groups and supergroups only
#[must_use]
pub fn can_manage_tags_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_manage_tags = val.map(Into::into);
this
}
}
impl super::TelegramMethod for PromoteChatMember {
type Method = Self;
type Return = bool;
fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
super::Request::new("promoteChatMember", self, None)
}
}