telegram.User

class telegram.User(id, first_name, is_bot, last_name=None, username=None, language_code=None, can_join_groups=None, can_read_all_group_messages=None, supports_inline_queries=None, bot=None, **kwargs)

Bases: telegram.base.TelegramObject

This object represents a Telegram user or bot.

id

Unique identifier for this user or bot.

Type:int
is_bot

True, if this user is a bot

Type:bool
first_name

User’s or bot’s first name.

Type:str
last_name

Optional. User’s or bot’s last name.

Type:str
username

Optional. User’s or bot’s username.

Type:str
language_code

Optional. IETF language tag of the user’s language.

Type:str
can_join_groups

Optional. True, if the bot can be invited to groups. Returned only in telegram.Bot.get_me requests.

Type:str
can_read_all_group_messages

Optional. True, if privacy mode is disabled for the bot. Returned only in telegram.Bot.get_me requests.

Type:str
supports_inline_queries

Optional. True, if the bot supports inline queries. Returned only in telegram.Bot.get_me requests.

Type:str
bot

Optional. The Bot to use for instance methods.

Type:telegram.Bot
Parameters:
  • id (int) – Unique identifier for this user or bot.
  • is_bot (bool) – True, if this user is a bot
  • first_name (str) – User’s or bot’s first name.
  • last_name (str, optional) – User’s or bot’s last name.
  • username (str, optional) – User’s or bot’s username.
  • language_code (str, optional) – IETF language tag of the user’s language.
  • can_join_groups (str, optional) – True, if the bot can be invited to groups. Returned only in telegram.Bot.get_me requests.
  • can_read_all_group_messages (str, optional) – True, if privacy mode is disabled for the bot. Returned only in telegram.Bot.get_me requests.
  • supports_inline_queries (str, optional) – True, if the bot supports inline queries. Returned only in telegram.Bot.get_me requests.
  • bot (telegram.Bot, optional) – The Bot to use for instance methods.
classmethod de_json(data, bot)
classmethod de_list(data, bot)
full_name

Convenience property. The user’s first_name, followed by (if available) last_name.

Type:str
get_profile_photos(*args, **kwargs)

Shortcut for:

bot.get_user_profile_photos(update.message.from_user.id, *args, **kwargs)

Convenience property. If username is available, returns a t.me link of the user.

Type:str
mention_html(name=None)
Parameters:name (str) – The name used as a link for the user. Defaults to full_name.
Returns:The inline mention for the user as HTML.
Return type:str
mention_markdown(name=None)
Parameters:name (str) – The name used as a link for the user. Defaults to full_name.
Returns:The inline mention for the user as markdown (version 1).
Return type:str
mention_markdown_v2(name=None)
Parameters:name (str) – The name used as a link for the user. Defaults to full_name.
Returns:The inline mention for the user as markdown (version 2).
Return type:str
name

Convenience property. If available, returns the user’s username prefixed with “@”. If username is not available, returns full_name.

Type:str
send_animation(*args, **kwargs)

Shortcut for:

bot.send_animation(User.id, *args, **kwargs)

Where User is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_audio(*args, **kwargs)

Shortcut for:

bot.send_audio(User.id, *args, **kwargs)

Where User is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_document(*args, **kwargs)

Shortcut for:

bot.send_document(User.id, *args, **kwargs)

Where User is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_message(*args, **kwargs)

Shortcut for:

bot.send_message(User.id, *args, **kwargs)

Where User is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_photo(*args, **kwargs)

Shortcut for:

bot.send_photo(User.id, *args, **kwargs)

Where User is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_sticker(*args, **kwargs)

Shortcut for:

bot.send_sticker(User.id, *args, **kwargs)

Where User is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_video(*args, **kwargs)

Shortcut for:

bot.send_video(User.id, *args, **kwargs)

Where User is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_video_note(*args, **kwargs)

Shortcut for:

bot.send_video_note(User.id, *args, **kwargs)

Where User is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_voice(*args, **kwargs)

Shortcut for:

bot.send_voice(User.id, *args, **kwargs)

Where User is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message