pub struct User {
pub first_name: String,
pub id: UserPeerId,
pub is_bot: bool,
pub added_to_attachment_menu: Option<bool>,
pub is_premium: Option<bool>,
pub language_code: Option<String>,
pub last_name: Option<String>,
pub username: Option<UserUsername>,
}
Expand description
Represents a user.
Fields§
§first_name: String
First name of the user.
id: UserPeerId
Unique identifier of the user.
is_bot: bool
Indicates whether the user is a bot.
Indicates whether the user added the bot to the attachment menu.
Indicates whether the user is a Telegram Premium user.
language_code: Option<String>
IETF language tag of the user’s language.
last_name: Option<String>
Last name of the user.
username: Option<UserUsername>
Username of the user.
Implementations§
Source§impl User
impl User
Sourcepub fn new<A, B>(id: A, first_name: B, is_bot: bool) -> Self
pub fn new<A, B>(id: A, first_name: B, is_bot: bool) -> Self
Creates a new User
.
§Arguments
id
- Unique identifier of the user.first_name
- First name of the user.is_bot
- Indicates whether the user is a bot.
Sourcepub fn get_full_name(&self) -> String
pub fn get_full_name(&self) -> String
Returns the full name of the user (first name + last name).
Sourcepub fn get_link(&self) -> String
pub fn get_link(&self) -> String
Returns the link to the user (tg://user?id=xxx
).
These links will work only if they are used inside an inline link. For example, they will not work, when used in an inline keyboard button or in a message text.
Sourcepub fn get_link_mention(
&self,
parse_mode: ParseMode,
) -> Result<String, MentionError>
pub fn get_link_mention( &self, parse_mode: ParseMode, ) -> Result<String, MentionError>
Returns the mention for the user.
§Arguments
parse_mode
- A parse mode for formatting the mention.
These mentions are only guaranteed to work if the user has contacted the bot in the past, has sent a callback query to the bot via inline button or is a member in the group where he was mentioned.
Sets a new value for the added_to_attachment_menu
flag.
§Arguments
value
- Indicates whether the user added the bot to the attachment menu.
Sets a new value for the is_premium
flag.
§Arguments
value
- Indicates whether the user is a Telegram Premium user.