teloxide_core/types/
external_reply_info.rs

1use serde::{Deserialize, Serialize};
2
3use crate::types::{
4    Animation, Audio, Chat, Contact, Dice, Document, Game, Giveaway, GiveawayWinners, Invoice,
5    LinkPreviewOptions, Location, MessageId, MessageOrigin, PhotoSize, Poll, Sticker, Story, Venue,
6    Video, VideoNote, Voice,
7};
8
9/// This object contains information about a message that is being replied to,
10/// which may come from another chat or forum topic.
11#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
12pub struct ExternalReplyInfo {
13    /// Origin of the message replied to by the given message.
14    pub origin: MessageOrigin,
15    /// Chat the original message belongs to. Available only if the chat is a
16    /// supergroup or a channel.
17    pub chat: Option<Chat>,
18    /// Unique message identifier inside the original chat. Available only if
19    /// the original chat is a supergroup or a channel.
20    #[serde(with = "crate::types::option_msg_id_as_int")]
21    pub message_id: Option<MessageId>,
22    /// Options used for link preview generation for the original message, if it
23    /// is a text message.
24    pub link_preview_options: Option<LinkPreviewOptions>,
25    /// _true_, if the message media is covered by a spoiler animation.
26    #[serde(default)]
27    pub has_media_spoiler: bool,
28
29    #[serde(flatten)]
30    pub kind: ExternalReplyInfoKind,
31}
32
33#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
34#[serde(rename_all = "snake_case")]
35pub enum ExternalReplyInfoKind {
36    // Note:
37    // - `Venue` must be in front of `Location`
38    // - `Animation` must be in front of `Document`
39    //
40    // This is needed so serde doesn't parse `Venue` as `Location` or `Animation` as `Document`
41    // (for backward compatability telegram duplicates some fields).
42    //
43    // See <https://github.com/teloxide/teloxide/issues/481>
44    Animation(Animation),
45    Audio(Audio),
46    Contact(Contact),
47    Dice(Dice),
48    Document(Document),
49    Game(Game),
50    Venue(Venue),
51    Location(Location),
52    Photo(Vec<PhotoSize>),
53    Poll(Poll),
54    Sticker(Sticker),
55    Story(Story),
56    Giveaway(Giveaway),
57    GiveawayWinners(GiveawayWinners),
58    Video(Video),
59    VideoNote(VideoNote),
60    Voice(Voice),
61    Invoice(Invoice),
62}