vaegram 0.3.0

Telegram MTProto client library for users and bots
Documentation
use crate::Client;
use crate::errors::Result;
use crate::methods::advanced::ChatPeer;
use crate::raw::functions;
use crate::types::PeerRef;

impl Client {
    /// Renames a basic group, supergroup or channel.
    pub async fn set_chat_title(&self, chat_id: impl Into<PeerRef>, title: impl Into<String>) -> Result<()> {
        let title = title.into();
        match self.resolve_chat(&chat_id.into()).await? {
            ChatPeer::Group(chat_id) => {
                self.invoke(&functions::messages::EditChatTitle { chat_id, title }).await?;
            }
            ChatPeer::Channel(channel) => {
                self.invoke(&functions::channels::EditTitle { channel, title }).await?;
            }
        }
        Ok(())
    }
}