vaegram 0.3.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::{base, functions};
use crate::types::{PeerRef, StarAmount};

impl Client {
    /// Returns the Star balance of a channel or bot the account owns.
    pub async fn get_star_balance(&self, chat_id: impl Into<PeerRef>) -> Result<StarAmount> {
        let peer = self.resolve_peer(chat_id).await?;
        let request = functions::payments::GetStarsStatus { ton: false, peer };
        let base::payments::StarsStatus::StarsStatus(status) = self.invoke(&request).await?;
        Ok(StarAmount::parse(&status.balance))
    }
}