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::errors::Result;
use crate::raw::{base, functions, types};
use crate::types::PeerRef;

impl Client {
    /// Pins a dialog of Saved Messages to the top.
    pub async fn pin_saved_dialog(&self, chat_id: impl Into<PeerRef>) -> Result<()> {
        self.toggle_saved_dialog_pin(chat_id, true).await
    }

    pub(crate) async fn toggle_saved_dialog_pin(&self, chat_id: impl Into<PeerRef>, pinned: bool) -> Result<()> {
        let peer = types::InputDialogPeer { peer: self.resolve_peer(chat_id).await? };
        let peer = base::InputDialogPeer::InputDialogPeer(Box::new(peer));
        self.invoke(&functions::messages::ToggleSavedDialogPin { pinned, peer }).await?;
        Ok(())
    }
}