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
use serde::{Deserialize, Serialize};
use super::user::User;
// ---------------------------------------------------------------------------
// ChatMember -- tagged union on the "status" field (wire values)
// ---------------------------------------------------------------------------
/// Represents a chat member that owns the chat and has all administrator privileges.
///
/// Wire value: `"creator"`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ChatMemberOwner {
/// Information about the user.
pub user: User,
/// True if the user's presence in the chat is hidden.
pub is_anonymous: bool,
/// Custom title for this user.
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_title: Option<String>,
}
/// Represents a chat member that has some additional privileges.
///
/// Wire value: `"administrator"`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ChatMemberAdministrator {
/// Information about the user.
pub user: User,
/// True if the bot is allowed to edit administrator privileges of that user.
pub can_be_edited: bool,
/// True if the user's presence in the chat is hidden.
pub is_anonymous: bool,
/// True if the administrator can access the chat event log and ignore slow mode.
pub can_manage_chat: bool,
/// True if the administrator can delete messages of other users.
pub can_delete_messages: bool,
/// True if the administrator can manage video chats.
pub can_manage_video_chats: bool,
/// True if the administrator can restrict, ban or unban chat members.
pub can_restrict_members: bool,
/// True if the administrator can add new administrators with a subset of their own privileges.
pub can_promote_members: bool,
/// True if the user can change the chat title, photo and other settings.
pub can_change_info: bool,
/// True if the user can invite new users to the chat.
pub can_invite_users: bool,
/// True if the administrator can post stories to the chat.
pub can_post_stories: bool,
/// True if the administrator can edit stories posted by other users.
pub can_edit_stories: bool,
/// True if the administrator can delete stories posted by other users.
pub can_delete_stories: bool,
/// True if the administrator can post messages in the channel; channels only.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_post_messages: Option<bool>,
/// True if the administrator can edit messages of other users; channels only.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_edit_messages: Option<bool>,
/// True if the user is allowed to pin messages; groups and supergroups only.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_pin_messages: Option<bool>,
/// True if the user is allowed to create, rename, close and reopen forum topics.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_topics: Option<bool>,
/// Custom title for this user.
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_title: Option<String>,
/// True if the administrator can manage direct messages of the channel; channels only.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_direct_messages: Option<bool>,
/// True if the administrator can edit the tags of regular members; groups and supergroups only.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_tags: Option<bool>,
}
/// Represents a chat member that has no additional privileges or restrictions.
///
/// Wire value: `"member"`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ChatMemberMember {
/// Information about the user.
pub user: User,
/// Unix timestamp of when the user's subscription will expire.
#[serde(skip_serializing_if = "Option::is_none")]
pub until_date: Option<i64>,
/// Tag of the member.
#[serde(skip_serializing_if = "Option::is_none")]
pub tag: Option<String>,
}
/// Represents a chat member that is under certain restrictions in the chat (supergroups only).
///
/// Wire value: `"restricted"`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ChatMemberRestricted {
/// Information about the user.
pub user: User,
/// True if the user is a member of the chat at the moment of the request.
pub is_member: bool,
/// True if the user can change the chat title, photo and other settings.
pub can_change_info: bool,
/// True if the user can invite new users to the chat.
pub can_invite_users: bool,
/// True if the user is allowed to pin messages.
pub can_pin_messages: bool,
/// True if the user is allowed to send text messages, contacts, invoices, locations and venues.
pub can_send_messages: bool,
/// True if the user is allowed to send polls.
pub can_send_polls: bool,
/// True if the user is allowed to send animations, games, stickers and use inline bots.
pub can_send_other_messages: bool,
/// True if the user is allowed to add web page previews to their messages.
pub can_add_web_page_previews: bool,
/// True if the user is allowed to create forum topics.
pub can_manage_topics: bool,
/// Unix timestamp of when restrictions will be lifted for this user.
pub until_date: i64,
/// True if the user is allowed to send audios.
pub can_send_audios: bool,
/// True if the user is allowed to send documents.
pub can_send_documents: bool,
/// True if the user is allowed to send photos.
pub can_send_photos: bool,
/// True if the user is allowed to send videos.
pub can_send_videos: bool,
/// True if the user is allowed to send video notes.
pub can_send_video_notes: bool,
/// True if the user is allowed to send voice notes.
pub can_send_voice_notes: bool,
/// True if the user is allowed to edit their own tag.
pub can_edit_tag: bool,
/// Tag of the member.
#[serde(skip_serializing_if = "Option::is_none")]
pub tag: Option<String>,
}
/// Represents a chat member that isn't currently a member of the chat but may join.
///
/// Wire value: `"left"`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ChatMemberLeft {
/// Information about the user.
pub user: User,
}
/// Represents a chat member that was banned and cannot return to or view the chat.
///
/// Wire value: `"kicked"`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ChatMemberBanned {
/// Information about the user.
pub user: User,
/// Unix timestamp of when restrictions will be lifted for this user.
pub until_date: i64,
}
/// Represents a member of a chat. Discriminated by the `"status"` field.
///
/// The Telegram API wire values are: `"creator"`, `"administrator"`, `"member"`,
/// `"restricted"`, `"left"`, `"kicked"`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "status")]
#[non_exhaustive]
pub enum ChatMember {
/// Chat creator (owner) with all privileges.
#[serde(rename = "creator")]
Owner(ChatMemberOwner),
/// Chat administrator with additional privileges.
#[serde(rename = "administrator")]
Administrator(ChatMemberAdministrator),
/// Regular chat member without additional privileges or restrictions.
#[serde(rename = "member")]
Member(ChatMemberMember),
/// Chat member under certain restrictions.
#[serde(rename = "restricted")]
Restricted(ChatMemberRestricted),
/// User that is not a member of the chat but may join.
#[serde(rename = "left")]
Left(ChatMemberLeft),
/// User that was banned from the chat.
#[serde(rename = "kicked")]
Banned(ChatMemberBanned),
}
// ---------------------------------------------------------------------------
// ChatOwnerChanged / ChatOwnerLeft -- from _chatowner.py
// These are service message types distinct from the ChatMember status system.
// ---------------------------------------------------------------------------
/// Service message about an ownership change in the chat.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ChatOwnerChanged {
/// The new owner of the chat.
pub new_owner: User,
}
/// Service message about the chat owner leaving the chat.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ChatOwnerLeft {
/// The user which will be the new owner of the chat if the previous owner does not return.
#[serde(skip_serializing_if = "Option::is_none")]
pub new_owner: Option<User>,
}