tgbot 0.47.0

A Telegram Bot library
Documentation
use serde::{Deserialize, Serialize};
use serde_json::Value;

use crate::types::{
    Animation,
    Audio,
    Chat,
    Checklist,
    Contact,
    Dice,
    Document,
    Game,
    Giveaway,
    GiveawayWinners,
    Integer,
    Invoice,
    LinkPreviewOptions,
    LivePhoto,
    Location,
    Message,
    MessageOrigin,
    PaidMediaInfo,
    PhotoSize,
    Poll,
    Sticker,
    Story,
    Venue,
    Video,
    VideoNote,
    Voice,
};

/// Contains information about a message or a story that is being replied to.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum ReplyTo {
    /// The original message.
    ///
    /// Note that the Message object in this field will not contain further
    /// `reply_to` fields even if it itself is a reply.
    #[serde(rename = "reply_to_message")]
    Message(Box<Message>),
    /// The original story.
    #[serde(rename = "reply_to_story")]
    Story(Story),
}

/// Contains information about a message that is being replied to, which may come from another chat or forum topic.
#[serde_with::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ExternalReplyInfo {
    /// Origin of the message replied to by the given message.
    pub origin: MessageOrigin,
    /// Chat the original message belongs to.
    ///
    /// Available only if the chat is a supergroup or a channel.
    pub chat: Option<Chat>,
    /// Whether the message media is covered by a spoiler animation.
    pub has_media_spoiler: Option<bool>,
    /// Options used for link preview generation for the original message, if it is a text message.
    pub link_preview_options: Option<LinkPreviewOptions>,
    /// Unique message identifier inside the original chat.
    ///
    /// Available only if the original chat is a supergroup or a channel.
    pub message_id: Option<Integer>,

    /// Contains data of the message.
    #[serde(flatten)]
    pub data: ExternalReplyData,
}

/// Contains data of an external reply info.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum ExternalReplyData {
    /// Message is an animation, information about the animation.
    Animation(Animation),
    /// Message is an audio file, information about the file.
    Audio(Audio),
    /// Message is a checklist
    Checklist(Checklist),
    /// Message is a shared contact, information about the contact.
    Contact(Contact),
    /// Message is a dice with random value.
    Dice(Dice),
    /// Message is a general file, information about the file.
    Document(Document),
    /// Message is a game, information about the game.
    Game(Game),
    /// Message is a scheduled giveaway, information about the giveaway.
    Giveaway(Giveaway),
    /// A giveaway with public winners was completed.
    GiveawayWinners(GiveawayWinners),
    /// Message is an invoice for a payment, information about the invoice.
    Invoice(Invoice),
    /// Message is a live photo, information about live photo.
    LivePhoto(LivePhoto),
    /// Message is a shared location, information about the location.
    Location(Location),
    /// Message contains paid media, information about the paid media.
    PaidMedia(PaidMediaInfo),
    /// Message is a photo, available sizes of the photo.
    Photo(Vec<PhotoSize>),
    /// Message is a native poll, information about the poll.
    Poll(Box<Poll>),
    /// Message is a sticker, information about the sticker.
    Sticker(Sticker),
    /// Message is a forwarded story.
    Story(Story),
    /// Message is a venue, information about the venue.
    Venue(Venue),
    /// Message is a video, information about the video.
    Video(Video),
    /// Message is a video note, information about the video message.
    VideoNote(VideoNote),
    /// Message is a voice message, information about the file.
    Voice(Voice),
    /// Contains arbitrary data for future variants.
    #[serde(untagged)]
    Unknown(Value),
}