telegram_bot_async_raw/requests/
stop_message_live_location.rs

1use crate::{requests::*, types::*};
2
3/// Use this method to stop updating a live location message sent by the bot
4/// before live_period expires.
5#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
6#[must_use = "requests do nothing unless sent"]
7pub struct StopMessageLiveLocation {
8    chat_id: ChatRef,
9    message_id: MessageId,
10    #[serde(skip_serializing_if = "Option::is_none")]
11    reply_markup: Option<ReplyMarkup>,
12}
13
14impl Request for StopMessageLiveLocation {
15    type Type = JsonRequestType<Self>;
16    type Response = JsonIdResponse<Message>;
17
18    fn serialize(&self) -> Result<HttpRequest, Error> {
19        Self::Type::serialize(RequestUrl::method("stopMessageLiveLocation"), self)
20    }
21}
22
23impl StopMessageLiveLocation {
24    pub fn new<C, M>(chat: C, message_id: M) -> Self
25    where
26        C: ToChatRef,
27        M: ToMessageId,
28    {
29        StopMessageLiveLocation {
30            chat_id: chat.to_chat_ref(),
31            message_id: message_id.to_message_id(),
32            reply_markup: None,
33        }
34    }
35
36    pub fn reply_markup<R>(mut self, reply_markup: R) -> Self
37    where
38        R: Into<ReplyMarkup>,
39    {
40        self.reply_markup = Some(reply_markup.into());
41        self
42    }
43}
44
45/// Stop updating a live location message sent by the bot.
46pub trait CanStopMessageLiveLocation {
47    fn stop_live_location(&self) -> StopMessageLiveLocation;
48}
49
50impl<M> CanStopMessageLiveLocation for M
51where
52    M: ToMessageId + ToSourceChat,
53{
54    fn stop_live_location(&self) -> StopMessageLiveLocation {
55        StopMessageLiveLocation::new(self.to_source_chat(), self.to_message_id())
56    }
57}