diff --git a/src/core/requests/mod.rs b/src/core/requests/mod.rs index 1876db11..c951f54c 100644 --- a/src/core/requests/mod.rs +++ b/src/core/requests/mod.rs @@ -96,3 +96,4 @@ pub mod send_media_group; pub mod send_audio; pub mod send_location; pub mod edit_message_live_location; +pub mod stop_message_live_location; \ No newline at end of file diff --git a/src/core/requests/stop_message_live_location.rs b/src/core/requests/stop_message_live_location.rs new file mode 100644 index 00000000..9f1fd027 --- /dev/null +++ b/src/core/requests/stop_message_live_location.rs @@ -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, + /// Required if inline_message_id is not specified. Identifier of the + /// message with live location to stop + message_id: Option, + /// Required if chat_id and message_id are not specified. Identifier of the + /// inline message + inline_message_id: Option, + /// A JSON-serialized object InlineKeyboardMarkup for a new inline + /// keyboard. + reply_markup: Option, +} + +impl<'a> Request<'a> for StopMessageLiveLocation<'a> { + type ReturnValue = Message; + + fn send(self) -> RequestFuture<'a, ResponseResult> { + 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(mut self, chat_id: T) -> Self + where T: Into + { + self.chat_id = chat_id.into(); + self + } + + pub fn message_id(mut self, message_id: T) -> Self + where T: Into + { + self.message_id = Some(message_id.into()); + self + } + + pub fn inline_message_id(mut self, inline_message_id: T) -> Self + where T: Into + { + self.inline_message_id = Some(inline_message_id.into()); + self + } + + pub fn reply_markup(mut self, reply_markup: T) -> Self + where T: Into + { + self.inline_message_id = Some(reply_markup.into()); + self + } +} \ No newline at end of file