mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Add field external_reply
of struct ExternalReplyInfo
to the Message
This commit is contained in:
parent
b625e813cc
commit
d42146fbc6
4 changed files with 69 additions and 3 deletions
|
@ -34,6 +34,7 @@ pub use dice_emoji::*;
|
|||
pub use document::*;
|
||||
pub use encrypted_credentials::*;
|
||||
pub use encrypted_passport_element::*;
|
||||
pub use external_reply_info::*;
|
||||
pub use file::*;
|
||||
pub use force_reply::*;
|
||||
pub use forum_topic::*;
|
||||
|
@ -180,6 +181,7 @@ mod contact;
|
|||
mod dice;
|
||||
mod dice_emoji;
|
||||
mod document;
|
||||
mod external_reply_info;
|
||||
mod file;
|
||||
mod force_reply;
|
||||
mod forum_topic;
|
||||
|
@ -443,7 +445,6 @@ pub(crate) mod option_url_from_string {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) mod option_msg_id_as_int {
|
||||
use crate::types::MessageId;
|
||||
|
||||
|
|
60
crates/teloxide-core/src/types/external_reply_info.rs
Normal file
60
crates/teloxide-core/src/types/external_reply_info.rs
Normal file
|
@ -0,0 +1,60 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{
|
||||
Animation, Audio, Chat, Contact, Dice, Document, Game, Giveaway, GiveawayWinners, Invoice,
|
||||
LinkPreviewOptions, Location, MessageId, MessageOrigin, PhotoSize, Poll, Sticker, Story, Venue,
|
||||
Video, VideoNote, Voice,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
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>,
|
||||
/// Unique message identifier inside the original chat. Available only if
|
||||
/// the original chat is a supergroup or a channel.
|
||||
#[serde(with = "crate::types::option_msg_id_as_int")]
|
||||
pub message_id: Option<MessageId>,
|
||||
/// Options used for link preview generation for the original message, if it
|
||||
/// is a text message
|
||||
pub link_preview_options: Option<LinkPreviewOptions>,
|
||||
/// _true_, if the message media is covered by a spoiler animation
|
||||
#[serde(default)]
|
||||
pub has_media_spoiler: bool,
|
||||
|
||||
#[serde(flatten)]
|
||||
pub kind: ExternalReplyInfoKind,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ExternalReplyInfoKind {
|
||||
// Note:
|
||||
// - `Venue` must be in front of `Location`
|
||||
// - `Animation` must be in front of `Document`
|
||||
//
|
||||
// This is needed so serde doesn't parse `Venue` as `Location` or `Animation` as `Document`
|
||||
// (for backward compatability telegram duplicates some fields)
|
||||
//
|
||||
// See <https://github.com/teloxide/teloxide/issues/481>
|
||||
Animation(Animation),
|
||||
Audio(Audio),
|
||||
Contact(Contact),
|
||||
Dice(Dice),
|
||||
Document(Document),
|
||||
Game(Game),
|
||||
Venue(Venue),
|
||||
Location(Location),
|
||||
Photo(Vec<PhotoSize>),
|
||||
Poll(Poll),
|
||||
Sticker(Sticker),
|
||||
Story(Story),
|
||||
Giveaway(Giveaway),
|
||||
GiveawayWinners(GiveawayWinners),
|
||||
Video(Video),
|
||||
VideoNote(VideoNote),
|
||||
Voice(Voice),
|
||||
Invoice(Invoice),
|
||||
}
|
|
@ -6,8 +6,8 @@ use url::Url;
|
|||
|
||||
use crate::types::{
|
||||
Animation, Audio, BareChatId, Chat, ChatId, ChatShared, Contact, Dice, Document,
|
||||
ForumTopicClosed, ForumTopicCreated, ForumTopicEdited, ForumTopicReopened, Game,
|
||||
GeneralForumTopicHidden, GeneralForumTopicUnhidden, Giveaway, GiveawayCompleted,
|
||||
ExternalReplyInfo, ForumTopicClosed, ForumTopicCreated, ForumTopicEdited, ForumTopicReopened,
|
||||
Game, GeneralForumTopicHidden, GeneralForumTopicUnhidden, Giveaway, GiveawayCompleted,
|
||||
GiveawayCreated, GiveawayWinners, InlineKeyboardMarkup, Invoice, LinkPreviewOptions, Location,
|
||||
MaybeInaccessibleMessage, MessageAutoDeleteTimerChanged, MessageEntity, MessageEntityRef,
|
||||
MessageId, MessageOrigin, PassportData, PhotoSize, Poll, ProximityAlertTriggered, Sticker,
|
||||
|
@ -119,6 +119,10 @@ pub struct MessageCommon {
|
|||
/// itself is a reply.
|
||||
pub reply_to_message: Option<Box<Message>>,
|
||||
|
||||
/// Information about the message that is being replied to, which may come
|
||||
/// from another chat or forum topic
|
||||
pub external_reply: Option<ExternalReplyInfo>,
|
||||
|
||||
/// For replies that quote part of the original message, the quoted part of
|
||||
/// the message
|
||||
pub quote: Option<TextQuote>,
|
||||
|
|
|
@ -546,6 +546,7 @@ mod test {
|
|||
kind: MessageKind::Common(MessageCommon {
|
||||
reply_to_message: None,
|
||||
forward_origin: None,
|
||||
external_reply: None,
|
||||
quote: None,
|
||||
edit_date: None,
|
||||
media_kind: MediaKind::Text(MediaText {
|
||||
|
|
Loading…
Reference in a new issue