telegram_bot_async_raw/requests/
unpin_chat_message.rs

1use crate::{requests::*, types::*};
2
3///Use this method to unpin a message in a supergroup or a channel.
4/// The bot must be an administrator in the chat for this to work
5/// and must have the ‘can_pin_messages’ admin right in the
6/// supergroup or ‘can_edit_messages’ admin right in the channel.
7#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
8#[must_use = "requests do nothing unless sent"]
9pub struct UnpinChatMessage {
10    chat_id: ChatRef,
11}
12
13impl Request for UnpinChatMessage {
14    type Type = JsonRequestType<Self>;
15    type Response = JsonTrueToUnitResponse;
16
17    fn serialize(&self) -> Result<HttpRequest, Error> {
18        Self::Type::serialize(RequestUrl::method("unpinChatMessage"), self)
19    }
20}
21
22impl UnpinChatMessage {
23    fn new<C>(chat: C) -> Self
24    where
25        C: ToChatRef,
26    {
27        Self {
28            chat_id: chat.to_chat_ref(),
29        }
30    }
31}
32
33pub trait CanUnpinMessage {
34    fn unpin_message(&self) -> UnpinChatMessage;
35}
36
37impl<C> CanUnpinMessage for C
38where
39    C: ToChatRef,
40{
41    fn unpin_message(&self) -> UnpinChatMessage {
42        UnpinChatMessage::new(self)
43    }
44}