pub struct User {
pub raw: User,
}
Expand description
A user.
Users include your contacts, members of a group, bot accounts created by @BotFather, or anyone with a Telegram account.
A “normal” (non-bot) user may also behave like a “bot” without actually being one, for example, when controlled with a program as opposed to being controlled by a human through a Telegram application. These are commonly known as “userbots”, and some people use them to enhance their Telegram experience (for example, creating “commands” so that the program automatically reacts to them, like translating messages).
Fields§
§raw: User
Implementations§
Source§impl User
impl User
pub fn from_raw(user: User) -> Self
Sourcepub fn status(&self) -> &UserStatus
pub fn status(&self) -> &UserStatus
Return the user presence status (also known as “last seen”).
Sourcepub fn pack(&self) -> PackedChat
pub fn pack(&self) -> PackedChat
Pack this user into a smaller representation that can be loaded later.
Sourcepub fn first_name(&self) -> &str
pub fn first_name(&self) -> &str
Return the first name of this user.
If the account was deleted, the returned string will be empty.
Sourcepub fn full_name(&self) -> String
pub fn full_name(&self) -> String
Return the full name of this user.
This is equal to the user’s first name concatenated with the user’s last name, if this is not empty. Otherwise, it equals the user’s first name.
Sourcepub fn username(&self) -> Option<&str>
pub fn username(&self) -> Option<&str>
Return the public @username of this user, if any.
The returned username does not contain the “@” prefix.
Outside of the application, people may link to this user with one of Telegram’s URLs, such as https://t.me/username.
Sourcepub fn usernames(&self) -> Vec<&str>
pub fn usernames(&self) -> Vec<&str>
Return collectible usernames of this chat, if any.
The returned usernames do not contain the “@” prefix.
Outside of the application, people may link to this user with one of its username, such as https://t.me/username.
Sourcepub fn phone(&self) -> Option<&str>
pub fn phone(&self) -> Option<&str>
Return the phone number of this user, if they are not a bot and their privacy settings allow you to see it.
Sourcepub fn photo(&self) -> Option<&UserProfilePhoto>
pub fn photo(&self) -> Option<&UserProfilePhoto>
Return the photo of this user, if any.
Sourcepub fn mutual_contact(&self) -> bool
pub fn mutual_contact(&self) -> bool
Is this user a mutual contact?
Contacts are mutual if both the user of the current account and this user have eachother in their respective contact list.
Sourcepub fn is_bot(&self) -> bool
pub fn is_bot(&self) -> bool
Is the current account a bot?
Bot accounts are those created by @BotFather.
Sourcepub fn bot_privacy(&self) -> bool
pub fn bot_privacy(&self) -> bool
If the current user is a bot, does it have privacy mode enabled?
- Bots with privacy enabled won’t see messages in groups unless they are replied or the
command includes their name (
/command@bot
). - Bots with privacy disabled will be able to see all messages in a group.
Sourcepub fn bot_supports_chats(self) -> bool
pub fn bot_supports_chats(self) -> bool
If the current user is a bot, can it be added to groups?
Sourcepub fn verified(&self) -> bool
pub fn verified(&self) -> bool
Has the account of this user been verified?
Verified accounts, such as @BotFather, have a special icon next to their names in official applications (commonly a blue starred checkmark).
Sourcepub fn restricted(&self) -> bool
pub fn restricted(&self) -> bool
Does this user have restrictions applied to their account?
Sourcepub fn bot_inline_geo(&self) -> bool
pub fn bot_inline_geo(&self) -> bool
If the current user is a bot, does it want geolocation information on inline queries?
Sourcepub fn restriction_reason(&self) -> Vec<RestrictionReason>
pub fn restriction_reason(&self) -> Vec<RestrictionReason>
The reason(s) why this user is restricted, could be empty.
Sourcepub fn bot_inline_placeholder(&self) -> Option<&str>
pub fn bot_inline_placeholder(&self) -> Option<&str>
Return the placeholder for inline queries if the current user is a bot and has said placeholder configured.