mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
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:
parent
fedc346e23
commit
7cf5ad5272
2 changed files with 116 additions and 3 deletions
117
src/bot/mod.rs
117
src/bot/mod.rs
|
@ -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()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue