This commit is contained in:
P0lunin 2019-09-09 18:43:20 +03:00
parent 826f52ff90
commit 7809356546

View file

@ -1,22 +1,60 @@
use crate::core::requests::{ChatId, Request, RequestFuture, ResponseResult, RequestContext}; use crate::core::{
use crate::core::types::{InputFile, ParseMode, Message}; network,
use crate::core::requests::form_builder::FormBuilder; requests::{ChatId, Request, RequestFuture, ResponseResult, RequestContext},
use crate::core::network; requests::form_builder::FormBuilder,
types::{InputFile, ParseMode, Message},
};
/// Use this method to send audio files, if you want Telegram clients to display
/// them in the music player. Your audio must be in the .mp3 format. On success,
/// the sent [`Message`] is returned. Bots can currently send audio files of up
/// to 50 MB in size, this limit may be changed in the future.
///
/// For sending voice messages, use the [`SendVoice`] method instead.
pub struct SendAudio<'a> { pub struct SendAudio<'a> {
ctx: RequestContext<'a>, ctx: RequestContext<'a>,
chat_id: ChatId, /// Unique identifier for the target chat or username of the target channel
audio: InputFile, /// (in the format @channelusername)
caption: Option<String>, pub chat_id: ChatId,
parse_mode: Option<ParseMode>, /// Audio to send.
duration: Option<i32>, /// [`InputFile::FileId`] - Pass a file_id as String to send an audio that
performer: Option<String>, /// exists on the Telegram servers (recommended).
title: Option<String>, /// [`InputFile::Url`] - Pass an HTTP URL as a String for Telegram
thumb: Option<InputFile>, /// to get an audio from the Internet.
disable_notification: Option<bool>, /// [`InputFile::File`] - Upload a new audio.
reply_to_message_id: Option<i64>, pub audio: InputFile,
reply_markup: Option<()> // TODO: add reply_markup /// Audio caption, 0-1024 characters
pub caption: Option<String>,
/// Send [Markdown] or [HTML],
/// if you want Telegram apps to show [bold, italic, fixed-width text
/// or inline URLs] in the media caption.
///
/// [Markdown]: crate::core::types::ParseMode::Markdown
/// [Html]: crate::core::types::ParseMode::Html
/// [bold, italic, fixed-width text or inline URLs]:
/// crate::core::types::ParseMode
pub parse_mode: Option<ParseMode>,
/// Duration of the audio in seconds
pub duration: Option<i32>,
/// Performer
pub performer: Option<String>,
/// Track name
pub title: Option<String>,
/// Thumbnail of the file sent; can be ignored if thumbnail generation for
/// the file is supported server-side. The thumbnail should be in JPEG
/// format and less than 200 kB in size. A thumbnails width and height
/// should not exceed 320. Thumbnails cant be reused and can be only
/// uploaded as a new file, so you can pass “attach://<file_attach_name>”
/// if the thumbnail was uploaded using multipart/form-data under
/// <file_attach_name>
pub thumb: Option<InputFile>,
/// Sends the message silently. Users will receive a notification with no
/// sound.
pub disable_notification: Option<bool>,
/// If the message is a reply, ID of the original message
pub reply_to_message_id: Option<i64>,
pub reply_markup: Option<()> // TODO: add reply_markup
} }
impl<'a> Request<'a> for SendAudio<'a> { impl<'a> Request<'a> for SendAudio<'a> {