telegram_bot_raw/requests/
get_chat_administrators.rs

1use crate::requests::*;
2use crate::types::*;
3
4/// Use this method to get a list of administrators in a chat.
5/// If the chat is a group or a supergroup and no administrators were appointed,
6/// only the creator will be returned.
7#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
8#[must_use = "requests do nothing unless sent"]
9pub struct GetChatAdministrators {
10    chat_id: ChatRef,
11}
12
13impl Request for GetChatAdministrators {
14    type Type = JsonRequestType<Self>;
15    type Response = JsonIdResponse<Vec<ChatMember>>;
16
17    fn serialize(&self) -> Result<HttpRequest, Error> {
18        Self::Type::serialize(RequestUrl::method("getChatAdministrators"), self)
19    }
20}
21
22impl GetChatAdministrators {
23    pub fn new<C>(chat: C) -> Self
24    where
25        C: ToChatRef,
26    {
27        GetChatAdministrators {
28            chat_id: chat.to_chat_ref(),
29        }
30    }
31}
32
33/// Get a list of administrators in a chat.
34pub trait CanGetChatAdministrators {
35    fn get_administrators(&self) -> GetChatAdministrators;
36}
37
38impl<C> CanGetChatAdministrators for C
39where
40    C: ToChatRef,
41{
42    fn get_administrators(&self) -> GetChatAdministrators {
43        GetChatAdministrators::new(self)
44    }
45}