Merge pull request #67 from telebofr/issue_input_file

changed where necessary String to InputFile
This commit is contained in:
Temirkhan Myrzamadi 2019-10-17 16:03:42 +00:00 committed by GitHub
commit 8b4fbe4bb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 37 deletions

View file

@ -247,7 +247,7 @@ impl Bot {
) -> SendVideoNote
where
C: Into<ChatId>,
V: Into<String>, // TODO: InputFile
V: Into<InputFile>,
{
SendVideoNote::new(self, chat_id, video_note)
}
@ -255,7 +255,7 @@ impl Bot {
pub fn send_voice<C, V>(&self, chat_id: C, voice: V) -> SendVoice
where
C: Into<ChatId>,
V: Into<String>, // TODO: InputFile
V: Into<InputFile>,
{
SendVoice::new(self, chat_id, voice)
}

View file

@ -3,7 +3,7 @@ use async_trait::async_trait;
use crate::bot::Bot;
use crate::network;
use crate::requests::{Request, ResponseResult};
use crate::types::{ChatId, Message, ParseMode, ReplyMarkup};
use crate::types::{ChatId, Message, ParseMode, ReplyMarkup, InputFile};
///TODO: add to bot api
///Use this method to send animation files (GIF or H.264/MPEG-4 AVC video
@ -21,8 +21,7 @@ pub struct SendAnimation<'a> {
/// exists on the Telegram servers (recommended), pass an HTTP URL as a
/// String for Telegram to get an animation from the Internet, or upload a
/// new animation using multipart/form-data. More info on Sending Files »
pub animation: String,
// InputFile or String
pub animation: InputFile,
///Duration of sent animation in seconds
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option<u64>,
@ -41,8 +40,7 @@ pub struct SendAnimation<'a> {
/// if the thumbnail was uploaded using multipart/form-data under
/// <file_attach_name> »
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb: Option<String>,
// InputFile or String Optional
pub thumb: Option<InputFile>,
///Animation caption (may also be used when resending animation by
/// file_id), 0-1024 characters
#[serde(skip_serializing_if = "Option::is_none")]
@ -90,7 +88,7 @@ impl<'a> SendAnimation<'a> {
pub(crate) fn new<C, S>(bot: &'a Bot, chat_id: C, animation: S) -> Self
where
C: Into<ChatId>,
S: Into<String>,
S: Into<InputFile>,
{
Self {
bot,
@ -140,7 +138,7 @@ impl<'a> SendAnimation<'a> {
}
pub fn thumb<T>(mut self, value: T) -> Self
where
T: Into<String>,
T: Into<InputFile>,
{
self.thumb = Some(value.into());
self

View file

@ -4,7 +4,7 @@ use crate::bot::Bot;
use crate::{
network,
requests::{Request, ResponseResult},
types::{ChatId, Message, ParseMode, ReplyMarkup},
types::{ChatId, Message, ParseMode, ReplyMarkup, InputFile},
};
// TODO: add method to bot/api
@ -23,8 +23,7 @@ pub struct SendDocument<'a> {
/// the Telegram servers (recommended), pass an HTTP URL as a String for
/// Telegram to get a file from the Internet, or upload a new one using
/// multipart/form-data.»
pub document: String,
//InputFile or String
pub document: InputFile,
/// 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
@ -34,8 +33,7 @@ pub struct SendDocument<'a> {
/// if the thumbnail was uploaded using multipart/form-data under
/// <file_attach_name>. More info on Sending Files »
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb: Option<String>,
//InputFile or String
pub thumb: Option<InputFile>,
/// Document caption (may also be used when resending documents by
/// file_id), 0-1024 characters
#[serde(skip_serializing_if = "Option::is_none")]
@ -83,7 +81,7 @@ impl<'a> SendDocument<'a> {
pub(crate) fn new<C, D>(bot: &'a Bot, chat_id: C, document: D) -> Self
where
C: Into<ChatId>,
D: Into<String>,
D: Into<InputFile>,
{
Self {
bot,
@ -108,7 +106,7 @@ impl<'a> SendDocument<'a> {
pub fn document<T>(mut self, value: T) -> Self
where
T: Into<String>,
T: Into<InputFile>,
{
self.document = value.into();
self
@ -116,7 +114,7 @@ impl<'a> SendDocument<'a> {
pub fn thumb<T>(mut self, value: T) -> Self
where
T: Into<String>,
T: Into<InputFile>,
{
self.thumb = Some(value.into());
self

View file

@ -3,7 +3,7 @@ use async_trait::async_trait;
use crate::bot::Bot;
use crate::network;
use crate::requests::{Request, ResponseResult};
use crate::types::{ChatId, Message, ParseMode, ReplyMarkup};
use crate::types::{ChatId, Message, ParseMode, ReplyMarkup, InputFile};
//TODO: add action to bot api
///Use this method to send video files, Telegram clients support mp4 videos
@ -21,7 +21,7 @@ pub struct SendVideo<'a> {
/// the Telegram servers (recommended), pass an HTTP URL as a String for
/// Telegram to get a video from the Internet, or upload a new video using
/// multipart/form-data. More info on Sending Files »
pub video: String,
pub video: InputFile,
///Duration of sent video in seconds
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option<u64>,
@ -40,8 +40,7 @@ pub struct SendVideo<'a> {
/// if the thumbnail was uploaded using multipart/form-data under
/// <file_attach_name>. More info on Sending Files »
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb: Option<String>,
//InputFile or String
pub thumb: Option<InputFile>,
///Video caption (may also be used when resending videos by file_id),
/// 0-1024 characters
#[serde(skip_serializing_if = "Option::is_none")]
@ -92,7 +91,7 @@ impl<'a> SendVideo<'a> {
pub(crate) fn new<C, V>(bot: &'a Bot, chat_id: C, video: V) -> Self
where
C: Into<ChatId>,
V: Into<String>,
V: Into<InputFile>,
{
Self {
bot,
@ -120,7 +119,7 @@ impl<'a> SendVideo<'a> {
pub fn video<T>(mut self, value: T) -> Self
where
T: Into<String>,
T: Into<InputFile>,
{
self.video = value.into();
self
@ -149,7 +148,7 @@ impl<'a> SendVideo<'a> {
}
pub fn thumb<T>(mut self, value: T) -> Self
where
T: Into<String>,
T: Into<InputFile>,
{
self.thumb = Some(value.into());
self

View file

@ -4,7 +4,7 @@ use crate::bot::Bot;
use crate::{
network,
requests::{Request, ResponseResult},
types::{ChatId, Message, ReplyMarkup},
types::{ChatId, Message, ReplyMarkup, InputFile},
};
///As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1
@ -21,8 +21,7 @@ pub struct SendVideoNote<'a> {
/// exists on the Telegram servers (recommended) or upload a new video
/// using multipart/form-data. More info on Sending Files ». Sending video
/// notes by a URL is currently unsupported
pub video_note: String,
// InputFile or String
pub video_note: InputFile,
///Duration of sent video in seconds
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option<u64>,
@ -38,8 +37,7 @@ pub struct SendVideoNote<'a> {
/// if the thumbnail was uploaded using multipart/form-data under
/// <file_attach_name>. More info on Sending Files »
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb: Option<String>,
// InputFile or String
pub thumb: Option<InputFile>,
///Sends the message silently. Users will receive a notification with no
/// sound.
#[serde(skip_serializing_if = "Option::is_none")]
@ -79,7 +77,7 @@ impl<'a> SendVideoNote<'a> {
pub(crate) fn new<C, V>(bot: &'a Bot, chat_id: C, video_note: V) -> Self
where
C: Into<ChatId>,
V: Into<String>,
V: Into<InputFile>,
{
Self {
bot,
@ -104,7 +102,7 @@ impl<'a> SendVideoNote<'a> {
pub fn video_note<T>(mut self, value: T) -> Self
where
T: Into<String>,
T: Into<InputFile>,
{
self.video_note = value.into();
self
@ -128,7 +126,7 @@ impl<'a> SendVideoNote<'a> {
pub fn thumb<T>(mut self, value: T) -> Self
where
T: Into<String>,
T: Into<InputFile>,
{
self.thumb = Some(value.into());
self

View file

@ -4,7 +4,7 @@ use crate::bot::Bot;
use crate::{
network,
requests::{Request, ResponseResult},
types::{ChatId, Message, ParseMode, ReplyMarkup},
types::{ChatId, Message, ParseMode, ReplyMarkup, InputFile},
};
///Use this method to send audio files, if you want Telegram clients to display
@ -24,8 +24,7 @@ pub struct SendVoice<'a> {
/// on the Telegram servers (recommended), pass an HTTP URL as a String for
/// Telegram to get a file from the Internet, or upload a new one using
/// multipart/form-data. More info on Sending Files »
pub voice: String,
//InputFile or String
pub voice: InputFile,
/// Voice message caption, 0-1024 characters
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>,
@ -76,7 +75,7 @@ impl<'a> SendVoice<'a> {
pub(crate) fn new<C, V>(bot: &'a Bot, chat_id: C, voice: V) -> Self
where
C: Into<ChatId>,
V: Into<String>,
V: Into<InputFile>,
{
Self {
bot,
@ -101,7 +100,7 @@ impl<'a> SendVoice<'a> {
pub fn voice<T>(mut self, value: T) -> Self
where
T: Into<String>,
T: Into<InputFile>,
{
self.voice = value.into();
self