add stop message live location handler

This commit is contained in:
nextel 2019-09-12 16:00:58 +03:00
parent a6c8942063
commit eada897471
2 changed files with 91 additions and 0 deletions

View file

@ -96,3 +96,4 @@ pub mod send_media_group;
pub mod send_audio; pub mod send_audio;
pub mod send_location; pub mod send_location;
pub mod edit_message_live_location; pub mod edit_message_live_location;
pub mod stop_message_live_location;

View file

@ -0,0 +1,90 @@
use std::path::Path;
use crate::core::{
network,
requests::{
ChatId, form_builder::FormBuilder, Request, RequestContext,
RequestFuture, ResponseResult,
},
types::{InlineKeyboardMarkup, Message, ParseMode},
};
/// Use this method to stop updating a live location message before live_period
/// expires. On success, if the message was sent by the bot, the sent Message is
/// returned, otherwise True is returned.
#[derive(Debug, Clone, Serialize)]
struct StopMessageLiveLocation<'a> {
ctx: RequestContext<'a>,
/// Required if inline_message_id is not specified. Unique identifier for
/// the target chat or username of the target channel (in the format
/// @channelusername)
chat_id: Option<ChatId>,
/// Required if inline_message_id is not specified. Identifier of the
/// message with live location to stop
message_id: Option<i32>,
/// Required if chat_id and message_id are not specified. Identifier of the
/// inline message
inline_message_id: Option<String>,
/// A JSON-serialized object InlineKeyboardMarkup for a new inline
/// keyboard.
reply_markup: Option<InlineKeyboardMarkup>,
}
impl<'a> Request<'a> for StopMessageLiveLocation<'a> {
type ReturnValue = Message;
fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> {
Box::pin(async move {
network::request_json(
&self.ctx.client,
&self.ctx.token,
"stopMessageLiveLocation",
&self,
)
.await
})
}
}
impl<'a> StopMessageLiveLocation<'a> {
fn new(
ctx: RequestContext<'a>,
chat_id: ChatId,
) -> Self {
Self {
ctx,
chat_id: None,
message_id: None,
inline_message_id: None,
reply_markup: None,
}
}
pub fn chat_id<T>(mut self, chat_id: T) -> Self
where T: Into<ChatId>
{
self.chat_id = chat_id.into();
self
}
pub fn message_id<T>(mut self, message_id: T) -> Self
where T: Into<i32>
{
self.message_id = Some(message_id.into());
self
}
pub fn inline_message_id<T>(mut self, inline_message_id: T) -> Self
where T: Into<String>
{
self.inline_message_id = Some(inline_message_id.into());
self
}
pub fn reply_markup<T>(mut self, reply_markup: T) -> Self
where T: Into<InlineKeyboardMarkup>
{
self.inline_message_id = Some(reply_markup.into());
self
}
}