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
use super::Text;
use crate::types::*;
#[derive(Debug, PartialEq, Clone)]
#[allow(clippy::large_enum_variant)]
pub enum Kind {
Text(Text),
Audio(Audio, Text),
Document(Document, Text),
Game(Game),
Photo(Vec<PhotoSize>, Text, Option<String>),
Sticker(Sticker),
Video(Video, Text, Option<String>),
Voice(Voice, Text),
VideoNote(VideoNote),
Contact(Contact),
Location(Location),
Venue(Venue),
Animation(Animation, Text),
Poll(Poll),
NewChatMembers(Vec<User>),
LeftChatMember(User),
NewChatTitle(String),
NewChatPhoto(Vec<PhotoSize>),
ChatPhotoDeleted,
GroupCreated,
SupergroupCreated,
ChannelCreated,
MigrateTo(chat::Id),
MigrateFrom(chat::Id),
Pinned(Box<Message>),
Invoice(Invoice),
SuccessfulPayment(SuccessfulPayment),
ConnectedWebsite(String),
PassportData(passport::Data),
Unknown,
}
impl Kind {
pub fn is_text(&self) -> bool {
match self {
Kind::Text(..) => true,
_ => false,
}
}
pub fn is_audio(&self) -> bool {
match self {
Kind::Audio(..) => true,
_ => false,
}
}
pub fn is_document(&self) -> bool {
match self {
Kind::Document(..) => true,
_ => false,
}
}
pub fn is_game(&self) -> bool {
match self {
Kind::Game(..) => true,
_ => false,
}
}
pub fn is_photo(&self) -> bool {
match self {
Kind::Photo(..) => true,
_ => false,
}
}
pub fn is_sticker(&self) -> bool {
match self {
Kind::Sticker(..) => true,
_ => false,
}
}
pub fn is_video(&self) -> bool {
match self {
Kind::Video(..) => true,
_ => false,
}
}
pub fn is_voice(&self) -> bool {
match self {
Kind::Voice(..) => true,
_ => false,
}
}
pub fn is_video_note(&self) -> bool {
match self {
Kind::VideoNote(..) => true,
_ => false,
}
}
pub fn is_contact(&self) -> bool {
match self {
Kind::Contact(..) => true,
_ => false,
}
}
pub fn is_location(&self) -> bool {
match self {
Kind::Location(..) => true,
_ => false,
}
}
pub fn is_venue(&self) -> bool {
match self {
Kind::Venue(..) => true,
_ => false,
}
}
pub fn is_animation(&self) -> bool {
match self {
Kind::Animation(..) => true,
_ => false,
}
}
pub fn is_poll(&self) -> bool {
match self {
Kind::Poll(..) => true,
_ => false,
}
}
pub fn is_new_chat_members(&self) -> bool {
match self {
Kind::NewChatMembers(..) => true,
_ => false,
}
}
pub fn is_left_chat_member(&self) -> bool {
match self {
Kind::LeftChatMember(..) => true,
_ => false,
}
}
pub fn is_new_chat_title(&self) -> bool {
match self {
Kind::NewChatTitle(..) => true,
_ => false,
}
}
pub fn is_new_chat_photo(&self) -> bool {
match self {
Kind::NewChatPhoto(..) => true,
_ => false,
}
}
pub fn is_chat_photo_deleted(&self) -> bool {
*self == Kind::ChatPhotoDeleted
}
pub fn is_group_created(&self) -> bool {
*self == Kind::GroupCreated
}
pub fn is_supergroup_created(&self) -> bool {
*self == Kind::SupergroupCreated
}
pub fn is_channel_created(&self) -> bool {
*self == Kind::ChannelCreated
}
pub fn is_migrate_to(&self) -> bool {
match self {
Kind::MigrateTo(..) => true,
_ => false,
}
}
pub fn is_migrate_from(&self) -> bool {
match self {
Kind::MigrateFrom(..) => true,
_ => false,
}
}
pub fn is_pinned(&self) -> bool {
match self {
Kind::Pinned(..) => true,
_ => false,
}
}
pub fn is_invoice(&self) -> bool {
match self {
Kind::Invoice(..) => true,
_ => false,
}
}
pub fn is_successful_payment(&self) -> bool {
match self {
Kind::SuccessfulPayment(..) => true,
_ => false,
}
}
pub fn is_connected_website(&self) -> bool {
match self {
Kind::ConnectedWebsite(..) => true,
_ => false,
}
}
pub fn is_passport_data(&self) -> bool {
match self {
Kind::PassportData(..) => true,
_ => false,
}
}
}