telegram_bot_raw/requests/
unpin_chat_message.rs

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