Add Box::{edit_message_live_location, forward_message, send_audio, send_location, send_media_group, send_photo, stop_message_live_location} methods

This commit is contained in:
Waffle 2019-09-13 01:39:25 +03:00
parent fedc346e23
commit 7cf5ad5272
2 changed files with 116 additions and 3 deletions

View file

@ -1,7 +1,24 @@
use reqwest::r#async::Client;
use crate::core::requests::{
get_me::GetMe, send_message::SendMessage, ChatId, RequestContext,
use crate::core::{
types::{
InputFile,
InputMedia,
},
requests::{
ChatId,
RequestContext,
get_me::GetMe,
send_message::SendMessage,
edit_message_live_location::EditMessageLiveLocation,
forward_message::ForwardMessage,
send_audio::SendAudio,
send_location::SendLocation,
send_media_group::SendMediaGroup,
send_photo::SendPhoto,
stop_message_live_location::StopMessageLiveLocation,
}
};
pub struct Bot {
@ -49,4 +66,100 @@ impl Bot {
text.into(),
)
}
pub fn edit_message_live_location<Lt, Lg>(
&self,
latitude: Lt,
longitude: Lg,
) -> EditMessageLiveLocation
where
Lt: Into<f64>,
Lg: Into<f64>,
{
EditMessageLiveLocation::new(
self.ctx(),
latitude.into(),
longitude.into(),
)
}
pub fn forward_message<C, F, M>(
&self,
chat_id: C,
from_chat_id: F,
message_id: M
) -> ForwardMessage
where
C: Into<ChatId>,
F: Into<ChatId>,
M: Into<i64>,
{
ForwardMessage::new(
self.ctx(),
chat_id.into(),
from_chat_id.into(),
message_id.into(),
)
}
pub fn send_audio<C, A>(&self, chat_id: C, audio: A) -> SendAudio
where
C: Into<ChatId>,
A: Into<InputFile>,
{
SendAudio::new(
self.ctx(),
chat_id.into(),
audio.into()
)
}
pub fn send_location<C, Lt, Lg>(
&self,
chat_id: C,
latitude: Lt,
longitude: Lg,
) -> SendLocation
where
C: Into<ChatId>,
Lt: Into<f64>,
Lg: Into<f64>,
{
SendLocation::new(
self.ctx(),
chat_id.into(),
latitude.into(),
longitude.into(),
)
}
pub fn send_media_group<C, M>(&self, chat_id: C, media: M) -> SendMediaGroup
where
C: Into<ChatId>,
M: Into<Vec<InputMedia>>
{
SendMediaGroup::new(
self.ctx(),
chat_id.into(),
media.into(),
)
}
pub fn send_photo<C, P>(&self, chat_id: C, photo: P) -> SendPhoto
where
C: Into<ChatId>,
P: Into<InputFile>
{
SendPhoto::new(
self.ctx(),
chat_id.into(),
photo.into(),
)
}
pub fn stop_message_live_location(&self) -> StopMessageLiveLocation {
StopMessageLiveLocation::new(
self.ctx()
)
}
}

View file

@ -53,7 +53,7 @@ impl<'a> Request<'a> for StopMessageLiveLocation<'a> {
}
impl<'a> StopMessageLiveLocation<'a> {
fn new(ctx: RequestContext<'a>) -> Self {
pub(crate) fn new(ctx: RequestContext<'a>) -> Self {
Self {
ctx,
chat_id: None,