pub struct User {
pub id: UserId,
pub is_bot: bool,
pub first_name: String,
pub last_name: Option<String>,
pub username: Option<String>,
pub language_code: Option<String>,
pub is_premium: bool,
pub added_to_attachment_menu: bool,
}
Expand description
This object represents a Telegram user or bot.
Fields§
§id: UserId
Unique identifier for this user or bot.
is_bot: bool
true
, if this user is a bot.
first_name: String
User‘s or bot’s first name.
last_name: Option<String>
User‘s or bot’s last name.
username: Option<String>
User‘s or bot’s username.
language_code: Option<String>
IETF language tag of the user’s language.
true
, if this user is a Telegram Premium user.
true
, if this user added the bot to the attachment menu.
Implementations§
source§impl User
impl User
sourcepub fn full_name(&self) -> String
pub fn full_name(&self) -> String
Returns full name of this user, ie first and last names joined with a space.
sourcepub fn mention(&self) -> Option<String>
pub fn mention(&self) -> Option<String>
Returns a username mention of this user. Returns None
if
self.username.is_none()
.
sourcepub fn url(&self) -> Url
pub fn url(&self) -> Url
Returns an URL that links to this user in the form of
tg://user/?id=<...>
.
sourcepub fn tme_url(&self) -> Option<Url>
pub fn tme_url(&self) -> Option<Url>
Returns an URL that links to this user in the form of t.me/<...>
.
Returns None
if self.username.is_none()
.
sourcepub fn preferably_tme_url(&self) -> Url
pub fn preferably_tme_url(&self) -> Url
Returns an URL that links to this user in the form of t.me/<...>
or
tg://user/?id=<...>
, preferring t.me
one when possible.
sourcepub fn is_anonymous(&self) -> bool
pub fn is_anonymous(&self) -> bool
Returns true
if this is the special user used by telegram bot API to
denote an anonymous user that sends messages on behalf of a group.
sourcepub fn is_channel(&self) -> bool
pub fn is_channel(&self) -> bool
Returns true
if this is the special user used by telegram bot API to
denote an anonymous user that sends messages on behalf of a channel.
sourcepub fn is_telegram(&self) -> bool
pub fn is_telegram(&self) -> bool
Returns true
if this is the special user used by telegram itself.
It is sometimes also used as a fallback, for example when a channel post
is automatically forwarded to a group, bots in a group will get a
message where from
is the Telegram user.
Trait Implementations§
source§impl<'de> Deserialize<'de> for User
impl<'de> Deserialize<'de> for User
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<User, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<User, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl PartialEq<User> for User
impl PartialEq<User> for User
source§impl Serialize for User
impl Serialize for User
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for User
impl StructuralEq for User
impl StructuralPartialEq for User
Auto Trait Implementations§
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnwindSafe for User
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.