telegram.User

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

Bases: telegram.base.TelegramObject

This object represents a Telegram user or bot.

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.

bot

telegram.Bot – Optional. The Bot to use for instance methods.

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.
  • bot (telegram.Bot, optional) – The Bot to use for instance methods.
classmethod de_json(data, bot)
classmethod de_list(data, bot)
full_name

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

get_profile_photos(*args, **kwargs)

Shortcut for:

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

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

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.
Return type:str
name

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

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