use super::{InlineKeyboardMarkup, InputMessageContent, MessageEntity}; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; /// Represents a link to an MP3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use `input_message_content` to send a message with the specified content instead of the audio. /// # Documentation /// #[skip_serializing_none] #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct InlineQueryResultAudio { /// Unique identifier for this result, 1-64 Bytes pub id: String, /// A valid URL for the audio file pub audio_url: String, /// Title pub title: String, /// Caption, 0-1024 characters after entities parsing pub caption: Option, /// Mode for parsing entities in the audio caption. See [`formatting options`](https://core.telegram.org/bots/api#formatting-options) for more details. pub parse_mode: Option, /// List of special entities that appear in the caption, which can be specified instead of *parse_mode* pub caption_entities: Option>, /// Performer pub performer: Option, /// Audio duration in seconds pub audio_duration: Option, /// [`Inline keyboard`](https://core.telegram.org/bots/features#inline-keyboards) attached to the message pub reply_markup: Option, /// Content of the message to be sent instead of the audio pub input_message_content: Option, } impl InlineQueryResultAudio { #[must_use] pub fn new( id: impl Into, audio_url: impl Into, title: impl Into, ) -> Self { Self { id: id.into(), audio_url: audio_url.into(), title: title.into(), caption: None, parse_mode: None, caption_entities: None, performer: None, audio_duration: None, reply_markup: None, input_message_content: None, } } #[must_use] pub fn id(self, val: impl Into) -> Self { Self { id: val.into(), ..self } } #[must_use] pub fn audio_url(self, val: impl Into) -> Self { Self { audio_url: val.into(), ..self } } #[must_use] pub fn title(self, val: impl Into) -> Self { Self { title: val.into(), ..self } } #[must_use] pub fn caption(self, val: impl Into) -> Self { Self { caption: Some(val.into()), ..self } } #[must_use] pub fn parse_mode(self, val: impl Into) -> Self { Self { parse_mode: Some(val.into()), ..self } } #[must_use] pub fn caption_entity(self, val: MessageEntity) -> Self { Self { caption_entities: Some( self.caption_entities .unwrap_or_default() .into_iter() .chain(Some(val)) .collect(), ), ..self } } #[must_use] pub fn caption_entities(self, val: impl IntoIterator) -> Self { Self { caption_entities: Some( self.caption_entities .unwrap_or_default() .into_iter() .chain(val) .collect(), ), ..self } } #[must_use] pub fn performer(self, val: impl Into) -> Self { Self { performer: Some(val.into()), ..self } } #[must_use] pub fn audio_duration(self, val: i64) -> Self { Self { audio_duration: Some(val), ..self } } #[must_use] pub fn reply_markup(self, val: impl Into) -> Self { Self { reply_markup: Some(val.into()), ..self } } #[must_use] pub fn input_message_content(self, val: impl Into) -> Self { Self { input_message_content: Some(val.into()), ..self } } } impl InlineQueryResultAudio { #[must_use] pub fn caption_option(self, val: Option>) -> Self { Self { caption: val.map(Into::into), ..self } } #[must_use] pub fn parse_mode_option(self, val: Option>) -> Self { Self { parse_mode: val.map(Into::into), ..self } } #[must_use] pub fn caption_entities_option( self, val: Option>, ) -> Self { Self { caption_entities: val.map(|val| { self.caption_entities .unwrap_or_default() .into_iter() .chain(val) .collect() }), ..self } } }