vaegram 0.2.0

Telegram MTProto client library for users and bots
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::Client;
use crate::dispatcher::Entities;
use crate::errors::Result;
use crate::raw::{base, functions};
use crate::types::{ChatSettings, PeerRef};

impl Client {
    /// Returns a chat's peer settings, such as whether you can report it as spam.
    pub async fn get_chat_settings(&self, chat_id: impl Into<PeerRef>) -> Result<ChatSettings> {
        let peer = self.resolve_peer(chat_id).await?;
        let base::messages::PeerSettings::PeerSettings(reply) =
            self.invoke(&functions::messages::GetPeerSettings { peer }).await?;
        let reply = *reply;
        let entities = Entities::new(self, reply.users, reply.chats);
        let base::PeerSettings::PeerSettings(settings) = reply.settings;
        Ok(ChatSettings::parse(*settings, &entities))
    }
}