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
use crate::Client;
use crate::errors::Result;
use crate::raw::functions;
use crate::types::PeerRef;

impl Client {
    /// Sets the public username of a channel or supergroup. `None` makes it private.
    pub async fn set_chat_username(&self, chat_id: impl Into<PeerRef>, username: Option<&str>) -> Result<()> {
        let channel = self.resolve_channel(&chat_id.into()).await?;
        let username = username.unwrap_or_default().to_owned();
        self.invoke(&functions::channels::UpdateUsername { channel, username }).await?;
        Ok(())
    }
}