Skip to main content

telers/methods/
get_chat.rs

1use crate::client::Bot;
2use serde::Serialize;
3/// Use this method to get up-to-date information about the chat. Returns a [`crate::types::ChatFullInfo`] object on success.
4/// # Documentation
5/// <https://core.telegram.org/bots/api#getchat>
6/// # Returns
7/// - `crate::types::ChatFullInfo`
8#[derive(Clone, Debug, Serialize)]
9pub struct GetChat {
10    /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
11    pub chat_id: crate::types::ChatIdKind,
12}
13impl GetChat {
14    /// Creates a new `GetChat`.
15    ///
16    /// # Arguments
17    /// * `chat_id` - Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
18    #[must_use]
19    pub fn new<T0: Into<crate::types::ChatIdKind>>(chat_id: T0) -> Self {
20        Self {
21            chat_id: chat_id.into(),
22        }
23    }
24
25    /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
26    #[must_use]
27    pub fn chat_id<T: Into<crate::types::ChatIdKind>>(self, val: T) -> Self {
28        let mut this = self;
29        this.chat_id = val.into();
30        this
31    }
32}
33impl super::TelegramMethod for GetChat {
34    type Method = Self;
35    type Return = crate::types::ChatFullInfo;
36
37    fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
38        super::Request::new("getChat", self, None)
39    }
40}