Struct User

Source
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

Source

pub fn from_raw(user: User) -> Self

Source

pub fn status(&self) -> &UserStatus

Return the user presence status (also known as “last seen”).

Source

pub fn id(&self) -> i64

Return the unique identifier for this user.

Source

pub fn pack(&self) -> PackedChat

Pack this user into a smaller representation that can be loaded later.

Source

pub fn first_name(&self) -> &str

Return the first name of this user.

If the account was deleted, the returned string will be empty.

Source

pub fn last_name(&self) -> Option<&str>

Return the last name of this user, if any.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn photo(&self) -> Option<&UserProfilePhoto>

Return the photo of this user, if any.

Source

pub fn is_self(&self) -> bool

Does this user represent the account that’s currently logged in?

Source

pub fn contact(&self) -> bool

Is this user in your account’s contact list?

Source

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.

Source

pub fn deleted(&self) -> bool

Has the account of this user been deleted?

Source

pub fn is_bot(&self) -> bool

Is the current account a bot?

Bot accounts are those created by @BotFather.

Source

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.
Source

pub fn bot_supports_chats(self) -> bool

If the current user is a bot, can it be added to groups?

Source

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).

Source

pub fn restricted(&self) -> bool

Does this user have restrictions applied to their account?

Source

pub fn bot_inline_geo(&self) -> bool

If the current user is a bot, does it want geolocation information on inline queries?

Source

pub fn support(&self) -> bool

Is this user an official member of the support team?

Source

pub fn scam(&self) -> bool

Has this user been flagged for trying to scam other people?

Source

pub fn restriction_reason(&self) -> Vec<RestrictionReason>

The reason(s) why this user is restricted, could be empty.

Source

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.

Source

pub fn lang_code(&self) -> Option<&str>

Language code of the user, if any.

Trait Implementations§

Source§

impl Clone for User

Source§

fn clone(&self) -> User

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for User

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&User> for PackedChat

Source§

fn from(chat: &User) -> Self

Converts to this type from the input type.
Source§

impl From<User> for PackedChat

Source§

fn from(chat: User) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for User

§

impl RefUnwindSafe for User

§

impl Send for User

§

impl Sync for User

§

impl Unpin for User

§

impl UnwindSafe for User

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.