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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
// Type out about 80 method names? No, thanks
#![allow(clippy::wildcard_imports)]
use crate::{
    contexts::fields,
    methods::*,
    types::{
        chat,
        input_file::{
            Animation, Audio, ChatPhoto, Document, EditableMedia, MediaGroup,
            Photo, Sticker, Video, VideoNote, Voice,
        },
        keyboard::inline,
        message,
        parameters::{poll, ImplicitChatId, Invoice, Text},
        user,
    },
};

/// Provides methods appliable to all messages.
pub trait Message: fields::Message {
    /// Copies a message to this chat.
    fn copy_here(
        &self,
        from_chat_id: impl ImplicitChatId,
        message_id: message::Id,
    ) -> CopyMessage<'_> {
        self.bot()
            .copy_message(self.chat().id, from_chat_id, message_id)
    }

    /// Copies a message in reply to this message.
    fn copy_here_in_reply(
        &self,
        from_chat_id: impl ImplicitChatId,
        message_id: message::Id,
    ) -> CopyMessage<'_> {
        self.bot()
            .copy_message(self.chat().id, from_chat_id, message_id)
            .in_reply_to(self.message_id())
    }

    /// Creates a secondary invite link for this chat.
    fn create_chat_invite_link(&self) -> CreateChatInviteLink<'_> {
        self.bot().create_chat_invite_link(self.chat().id)
    }

    /// Deletes the photo of this chat.
    fn delete_chat_photo(&self) -> DeleteChatPhoto<'_> {
        self.bot().delete_chat_photo(self.chat().id)
    }

    /// Deletes the sticker set of this chat.
    fn delete_chat_sticker_set(&self) -> DeleteChatStickerSet<'_> {
        self.bot().delete_chat_sticker_set(self.chat().id)
    }

    /// Deletes a message in this chat.
    fn delete_message(&self, message_id: message::Id) -> DeleteMessage<'_> {
        self.bot().delete_message(self.chat().id, message_id)
    }

    /// Deletes the incoming message.
    fn delete_this_message(&self) -> DeleteMessage<'_> {
        self.delete_message(self.message_id())
    }

    /// Edits a secondary invite link for this chat.
    fn edit_chat_invite_link(
        &self,
        link: impl Into<String>,
    ) -> EditChatInviteLink<'_> {
        self.bot().edit_chat_invite_link(self.chat().id, link)
    }

    /// Updates the caption of a message in this group.
    fn edit_message_caption(
        &self,
        message_id: message::Id,
        caption: impl Into<Text>,
    ) -> EditMessageCaption<'_> {
        self.bot()
            .edit_message_caption(self.chat().id, message_id, caption)
    }

    /// Updates a live location in this group.
    fn edit_message_location(
        &self,
        message_id: message::Id,
        location: (f64, f64),
    ) -> EditMessageLocation<'_> {
        self.bot()
            .edit_message_location(self.chat().id, message_id, location)
    }

    /// Updates the media of a message in this group.
    fn edit_message_media(
        &self,
        message_id: message::Id,
        media: impl Into<EditableMedia>,
    ) -> EditMessageMedia<'_> {
        self.bot()
            .edit_message_media(self.chat().id, message_id, media)
    }

    /// Updates the reply markup of a message in this group.
    fn edit_message_reply_markup(
        &self,
        message_id: message::Id,
        reply_markup: inline::Keyboard,
    ) -> EditMessageReplyMarkup<'_> {
        self.bot().edit_message_reply_markup(
            self.chat().id,
            message_id,
            reply_markup,
        )
    }

    /// Updates the text of a message in this group.
    fn edit_message_text(
        &self,
        message_id: message::Id,
        text: impl Into<Text>,
    ) -> EditMessageText<'_> {
        self.bot()
            .edit_message_text(self.chat().id, message_id, text)
    }

    /// Exports the invite link of this chat.
    fn export_chat_invite_link(&self) -> ExportChatInviteLink<'_> {
        self.bot().export_chat_invite_link(self.chat().id)
    }

    /// Forwards a message to this chat.
    fn forward_here(
        &self,
        from_chat_id: impl ImplicitChatId,
        message_id: message::Id,
    ) -> ForwardMessage<'_> {
        self.bot()
            .forward_message(self.chat().id, from_chat_id, message_id)
    }

    /// Gets information about this chat.
    fn get_chat(&self) -> GetChat<'_> {
        self.bot().get_chat(self.chat().id)
    }

    /// Gets a list of admins of this chat.
    fn get_chat_administrators(&self) -> GetChatAdministrators<'_> {
        self.bot().get_chat_administrators(self.chat().id)
    }

    /// Gets information about a member of this chat.
    fn get_chat_member(&self, user_id: user::Id) -> GetChatMember<'_> {
        self.bot().get_chat_member(self.chat().id, user_id)
    }

    /// Gets the number of members in this chat.
    fn get_chat_member_count(&self) -> GetChatMemberCount<'_> {
        self.bot().get_chat_member_count(self.chat().id)
    }

    /// Gets infomation about high scores in a game sent in this chat.
    fn get_message_game_high_scores(
        &self,
        message_id: message::Id,
        user_id: user::Id,
    ) -> GetMessageGameHighScores<'_> {
        self.bot().get_message_game_high_scores(
            self.chat().id,
            message_id,
            user_id,
        )
    }

    /// Bans a member of this chat.
    fn ban_chat_member(&self, user_id: user::Id) -> BanChatMember<'_> {
        self.bot().ban_chat_member(self.chat().id, user_id)
    }

    /// Leaves this chat.
    fn leave_chat(&self) -> LeaveChat<'_> {
        self.bot().leave_chat(self.chat().id)
    }

    /// Pins a message in this chat.
    fn pin_chat_message(&self, message_id: message::Id) -> PinChatMessage<'_> {
        self.bot().pin_chat_message(self.chat().id, message_id)
    }

    /// Promotes a member of this chat.
    fn promote_chat_member(&self, user_id: user::Id) -> PromoteChatMember<'_> {
        self.bot().promote_chat_member(self.chat().id, user_id)
    }

    /// Restricts a member of this chat.
    fn restrict_chat_member(
        &self,
        user_id: user::Id,
        permissions: chat::Permissions,
    ) -> RestrictChatMember<'_> {
        self.bot()
            .restrict_chat_member(self.chat().id, user_id, permissions)
    }

    /// Revokes an invite link for this chat.
    fn revoke_chat_invite_link(
        &self,
        link: impl Into<String>,
    ) -> RevokeChatInviteLink<'_> {
        self.bot().revoke_chat_invite_link(self.chat().id, link)
    }

    /// Send an animation to this chat.
    fn send_animation(&self, animation: Animation) -> SendAnimation<'_> {
        self.bot().send_animation(self.chat().id, animation)
    }

    /// Sends an animation in reply to this message.
    fn send_animation_in_reply(
        &self,
        animation: Animation,
    ) -> SendAnimation<'_> {
        self.send_animation(animation)
            .in_reply_to(self.message_id())
    }

    /// Sends an audio to this chat.
    fn send_audio(&self, audio: Audio) -> SendAudio<'_> {
        self.bot().send_audio(self.chat().id, audio)
    }

    /// Sends an audio in reply to this message.
    fn send_audio_in_reply(&self, audio: Audio) -> SendAudio<'_> {
        self.send_audio(audio).in_reply_to(self.message_id())
    }

    /// Sends an action to this group.
    fn send_chat_action(&self, action: chat::Action) -> SendChatAction<'_> {
        self.bot().send_chat_action(self.chat().id, action)
    }

    /// Sends a contact to this group.
    fn send_contact(
        &self,
        phone_number: impl Into<String>,
        first_name: impl Into<String>,
    ) -> SendContact<'_> {
        self.bot()
            .send_contact(self.chat().id, phone_number, first_name)
    }

    /// Sends a contact in reply to this message.
    fn send_contact_in_reply(
        &self,
        phone_number: impl Into<String>,
        first_name: impl Into<String>,
    ) -> SendContact<'_> {
        self.send_contact(phone_number, first_name)
            .in_reply_to(self.message_id())
    }

    /// Sends a game to this chat.
    fn send_game(&self, game_short_name: impl Into<String>) -> SendGame<'_> {
        self.bot().send_game(self.chat().id, game_short_name)
    }

    /// Sends a game in reply to this message.
    fn send_game_in_reply(
        &self,
        game_short_name: impl Into<String>,
    ) -> SendGame<'_> {
        self.send_game(game_short_name)
            .in_reply_to(self.message_id())
    }

    /// Sends a dice to this chat.
    fn send_dice(&self) -> SendDice<'_> {
        self.bot().send_dice(self.chat().id)
    }

    /// Sends a dice in reply to this message.
    fn send_dice_in_reply(&self) -> SendDice<'_> {
        self.send_dice().in_reply_to(self.message_id())
    }

    /// Sends a document to this chat.
    fn send_document(&self, document: Document) -> SendDocument<'_> {
        self.bot().send_document(self.chat().id, document)
    }

    /// Sends a document in reply to this message.
    fn send_document_in_reply(&self, document: Document) -> SendDocument<'_> {
        self.send_document(document).in_reply_to(self.message_id())
    }

    /// Sends an invoice to this chat.
    fn send_invoice(&self, invoice: Invoice) -> SendInvoice<'_> {
        self.bot().send_invoice(self.chat().id, invoice)
    }

    /// Sends an invoice in reply to this message.
    fn send_invoice_in_reply(&self, invoice: Invoice) -> SendInvoice<'_> {
        self.send_invoice(invoice).in_reply_to(self.message_id())
    }

    /// Sends a location to this chat.
    fn send_location(&self, location: (f64, f64)) -> SendLocation<'_> {
        self.bot().send_location(self.chat().id, location)
    }

    /// Sends a location in reply to this message.
    fn send_location_in_reply(&self, location: (f64, f64)) -> SendLocation<'_> {
        self.send_location(location).in_reply_to(self.message_id())
    }

    /// Sends an album to this chat.
    fn send_media_group(
        &self,
        media: impl Into<MediaGroup>,
    ) -> SendMediaGroup<'_> {
        self.bot().send_media_group(self.chat().id, media)
    }

    /// Sends an album in reply to this message.
    fn send_media_group_in_reply(
        &self,
        media: impl Into<MediaGroup>,
    ) -> SendMediaGroup<'_> {
        self.send_media_group(media).in_reply_to(self.message_id())
    }

    /// Sends a message to this chat.
    fn send_message(&self, text: impl Into<Text>) -> SendMessage<'_> {
        self.bot().send_message(self.chat().id, text)
    }

    /// Sends a message in reply to this message.
    fn send_message_in_reply(&self, text: impl Into<Text>) -> SendMessage<'_> {
        self.send_message(text).in_reply_to(self.message_id())
    }

    /// Sends a photo to this chat.
    fn send_photo(&self, photo: Photo) -> SendPhoto<'_> {
        self.bot().send_photo(self.chat().id, photo)
    }

    /// Sends a photo in reply to this message.
    fn send_photo_in_reply(&self, photo: Photo) -> SendPhoto<'_> {
        self.send_photo(photo).in_reply_to(self.message_id())
    }

    /// Sends a poll to this chat.
    fn send_poll(&self, poll: poll::Any) -> SendPoll<'_> {
        self.bot().send_poll(self.chat().id, poll)
    }

    /// Sends a poll in reply to this message.
    fn send_poll_in_reply(&self, poll: poll::Any) -> SendPoll<'_> {
        self.send_poll(poll).in_reply_to(self.message_id())
    }

    /// Sends a sticker to this chat.
    fn send_sticker(&self, sticker: Sticker) -> SendSticker<'_> {
        self.bot().send_sticker(self.chat().id, sticker)
    }

    /// Sends a sticker in reply to this message.
    fn send_sticker_in_reply(&self, sticker: Sticker) -> SendSticker<'_> {
        self.send_sticker(sticker).in_reply_to(self.message_id())
    }

    /// Sends a venue to this chat.
    fn send_venue(
        &self,
        location: (f64, f64),
        title: impl Into<String>,
        address: impl Into<String>,
    ) -> SendVenue<'_> {
        self.bot()
            .send_venue(self.chat().id, location, title, address)
    }

    /// Sends a venue in reply to this message.
    fn send_venue_in_reply(
        &self,
        location: (f64, f64),
        title: impl Into<String>,
        address: impl Into<String>,
    ) -> SendVenue<'_> {
        self.send_venue(location, title, address)
            .in_reply_to(self.message_id())
    }

    /// Sends a video to this chat.
    fn send_video(&self, video: Video) -> SendVideo<'_> {
        self.bot().send_video(self.chat().id, video)
    }

    /// Sends a video in reply to this message.
    fn send_video_in_reply(&self, video: Video) -> SendVideo<'_> {
        self.send_video(video).in_reply_to(self.message_id())
    }

    /// Sends a video note to this chat.
    fn send_video_note(&self, video_note: VideoNote) -> SendVideoNote<'_> {
        self.bot().send_video_note(self.chat().id, video_note)
    }

    /// Sends a video note in reply to this message.
    fn send_video_note_in_reply(
        &self,
        video_note: VideoNote,
    ) -> SendVideoNote<'_> {
        self.send_video_note(video_note)
            .in_reply_to(self.message_id())
    }

    /// Sends a voice to this chat.
    fn send_voice(&self, voice: Voice) -> SendVoice<'_> {
        self.bot().send_voice(self.chat().id, voice)
    }

    /// Sends a voice in reply to this message.
    fn send_voice_in_reply(&self, voice: Voice) -> SendVoice<'_> {
        self.send_voice(voice).in_reply_to(self.message_id())
    }

    /// Sets a custom title for an admin in this chat.
    fn set_chat_administrator_custom_title(
        &self,
        user_id: user::Id,
        custom_title: impl Into<String>,
    ) -> SetChatAdministratorCustomTitle<'_> {
        self.bot().set_chat_administrator_custom_title(
            self.chat().id,
            user_id,
            custom_title,
        )
    }

    /// Sets a new description of this chat.
    fn set_chat_description(
        &self,
        description: impl Into<String>,
    ) -> SetChatDescription<'_> {
        self.bot().set_chat_description(self.chat().id, description)
    }

    /// Sets new permissions of this chat.
    fn set_chat_permissions(
        &self,
        permissions: chat::Permissions,
    ) -> SetChatPermissions<'_> {
        self.bot().set_chat_permissions(self.chat().id, permissions)
    }

    /// Sets a new photo of this chat.
    fn set_chat_photo(&self, photo: ChatPhoto) -> SetChatPhoto<'_> {
        self.bot().set_chat_photo(self.chat().id, photo)
    }

    /// Sets a new sticker set of this chat.
    fn set_chat_sticker_set(
        &self,
        sticker_set_name: impl Into<String>,
    ) -> SetChatStickerSet<'_> {
        self.bot()
            .set_chat_sticker_set(self.chat().id, sticker_set_name)
    }

    /// Sets a new chat title of this chat.
    fn set_chat_title(&self, title: impl Into<String>) -> SetChatTitle<'_> {
        self.bot().set_chat_title(self.chat().id, title)
    }

    /// Sets a new high score for a player who played a game in this chat.
    fn set_message_game_score(
        &self,
        message_id: message::Id,
        user_id: user::Id,
        score: u32,
    ) -> SetMessageGameScore<'_> {
        self.bot().set_message_game_score(
            self.chat().id,
            message_id,
            user_id,
            score,
        )
    }

    /// Unbans a member of this chat.
    fn unban_chat_member(&self, user_id: user::Id) -> UnbanChatMember<'_> {
        self.bot().unban_chat_member(self.chat().id, user_id)
    }

    /// Unpins all messages in this chat.
    fn unpin_all_chat_messages(&self) -> UnpinAllChatMessages<'_> {
        self.bot().unpin_all_chat_messages(self.chat().id)
    }

    /// Unpins the pinned message in this chat.
    fn unpin_chat_message(&self) -> UnpinChatMessage<'_> {
        self.bot().unpin_chat_message(self.chat().id)
    }
}

impl<T: fields::Message> Message for T {}