1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
use serde::{Deserialize, Serialize};
use crate::file::PhotoSize;
use crate::{JsonMethod, TelegramMethod};
/// This object represents a Telegram user or bot.
#[derive(Serialize, Deserialize)]
pub struct User {
/// Unique identifier for this user or bot.
pub id: i64,
/// True, if this user is a bot
pub is_bot: bool,
/// User's or bot's first name
pub first_name: String,
/// User's or bot's last name
pub last_name: Option<String>,
/// User's or bot's username
pub username: Option<String>,
/// [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) of the user's language
pub language_code: Option<String>,
/// True, if the bot can be invited to groups.
/// Returned only in getMe.
pub can_join_groups: Option<bool>,
/// True, if [privacy mode](https://core.telegram.org/bots#privacy-mode) is disabled for the bot.
/// Returned only in getMe.
pub can_read_all_group_messages: Option<bool>,
/// True, if the bot supports inline queries.
/// Returned only in getMe.
pub supports_inline_queries: Option<bool>,
}
/// This object represent a user's profile pictures.
#[derive(Deserialize)]
pub struct UserProfilePhotos {
/// Total number of profile pictures the target user has
pub total_count: usize,
/// Requested profile pictures (in up to 4 sizes each)
pub photos: Vec<Vec<PhotoSize>>,
}
/// Use this method to get a list of profile pictures for a user.
/// Returns a [UserProfilePhotos] object.
#[derive(Serialize)]
pub struct GetUserProfilePhotos {
/// Unique identifier of the target user
user_id: i64,
/// Sequential number of the first photo to be returned. By default, all photos are returned.
offset: Option<u32>,
/// Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to 100.
limit: Option<u32>,
}
impl GetUserProfilePhotos {
/// Create a new getUserProfilePhotos request
pub fn new(user_id: i64) -> Self {
Self {
user_id,
offset: None,
limit: None,
}
}
/// Set offset
pub fn with_offset(self, offset: u32) -> Self {
Self {
offset: Some(offset),
..self
}
}
/// Set limit
pub fn with_limit(self, limit: u32) -> Self {
Self {
limit: Some(limit),
..self
}
}
}
impl TelegramMethod for GetUserProfilePhotos {
type Response = UserProfilePhotos;
fn name() -> &'static str {
"getUserProfilePhotos"
}
}
impl JsonMethod for GetUserProfilePhotos {}