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

impl Client {
    /// Returns the countries with their phone codes, named in `lang_code`.
    pub async fn get_countries_list(&self, lang_code: impl Into<String>) -> Result<Vec<Country>> {
        let request = functions::help::GetCountriesList { lang_code: lang_code.into(), hash: 0 };
        match self.invoke(&request).await? {
            base::help::CountriesList::CountriesList(l) => Ok(l.countries.into_iter().map(Country::parse).collect()),
            base::help::CountriesList::CountriesListNotModified => Ok(Vec::new()),
        }
    }
}