telegram.User

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

Bases: telegram.base.TelegramObject

This object represents a Telegram user or bot.

Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their id is equal.

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

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

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

Shortcut for:

bot.get_user_profile_photos(update.effective_user.id, *args, **kwargs)

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

Type:str
mention_html(name: str = None) → str
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: str = None) → str

Note

telegram.ParseMode.MARKDOWN is is a legacy mode, retained by Telegram for backward compatibility. You should use mention_markdown_v2() instead.

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: str = None) → str
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_action(*args, **kwargs) → bool

Alias for send_chat_action

send_animation(*args, **kwargs) → Message

Shortcut for:

bot.send_animation(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_audio(*args, **kwargs) → Message

Shortcut for:

bot.send_audio(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_chat_action(*args, **kwargs) → bool

Shortcut for:

bot.send_chat_action(update.effective_user.id, *args, **kwargs)
Returns:On success.
Return type:True
send_contact(*args, **kwargs) → Message

Shortcut for:

bot.send_contact(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_dice(*args, **kwargs) → Message

Shortcut for:

bot.send_dice(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_document(*args, **kwargs) → Message

Shortcut for:

bot.send_document(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_game(*args, **kwargs) → Message

Shortcut for:

bot.send_game(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_invoice(*args, **kwargs) → Message

Shortcut for:

bot.send_invoice(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_location(*args, **kwargs) → Message

Shortcut for:

bot.send_location(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_media_group(*args, **kwargs) → List[Message]

Shortcut for:

bot.send_media_group(update.effective_user.id, *args, **kwargs)
Returns:] On success, instance representing the message posted.
Return type:List[telegram.Message
send_message(*args, **kwargs) → Message

Shortcut for:

bot.send_message(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_photo(*args, **kwargs) → Message

Shortcut for:

bot.send_photo(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_poll(*args, **kwargs) → Message

Shortcut for:

bot.send_poll(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_sticker(*args, **kwargs) → Message

Shortcut for:

bot.send_sticker(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_venue(*args, **kwargs) → Message

Shortcut for:

bot.send_venue(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_video(*args, **kwargs) → Message

Shortcut for:

bot.send_video(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_video_note(*args, **kwargs) → Message

Shortcut for:

bot.send_video_note(update.effective_user.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_voice(*args, **kwargs) → Message

Shortcut for:

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