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 {
    /// Sets the chat theme by its emoji. An empty `emoji` removes the theme.
    pub async fn set_chat_theme(&self, chat_id: impl Into<PeerRef>, emoji: impl Into<String>) -> Result<()> {
        let emoticon = emoji.into();
        let theme = if emoticon.is_empty() {
            base::InputChatTheme::InputChatThemeEmpty
        } else {
            base::InputChatTheme::InputChatTheme(Box::new(types::InputChatTheme { emoticon }))
        };
        let peer = self.resolve_peer(chat_id).await?;
        self.invoke(&functions::messages::SetChatTheme { peer, theme }).await.map(drop)
    }
}