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.

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

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 bots first name.

  • last_name (str, optional) – User’s or bots last name.

  • username (str, optional) – User’s or bots 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.

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

copy_message(chat_id, message_id, caption=None, parse_mode=None, caption_entities=None, disable_notification=None, reply_to_message_id=None, allow_sending_without_reply=None, reply_markup=None, timeout=None, api_kwargs=None)

Shortcut for:

bot.copy_message(from_chat_id=update.effective_user.id, *args, **kwargs)

For the documentation of the arguments, please see telegram.Bot.copy_message().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

property full_name

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

Type

str

get_profile_photos(offset=None, limit=100, timeout=None, api_kwargs=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.get_user_profile_photos().

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)

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=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

property name

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

Type

str

pin_message(message_id, disable_notification=None, timeout=None, api_kwargs=None)

Shortcut for:

bot.pin_chat_message(chat_id=update.effective_user.id,
                     *args,
                     **kwargs)

For the documentation of the arguments, please see telegram.Bot.pin_chat_message().

Returns

On success, True is returned.

Return type

bool

send_action(action, timeout=None, api_kwargs=None)

Alias for send_chat_action

send_animation(animation, duration=None, width=None, height=None, thumb=None, caption=None, parse_mode=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_animation().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_audio(audio, duration=None, performer=None, title=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, parse_mode=None, thumb=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_audio().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_chat_action(action, timeout=None, api_kwargs=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_chat_action().

Returns

On success.

Return type

True

send_contact(phone_number=None, first_name=None, last_name=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, contact=None, vcard=None, api_kwargs=None, allow_sending_without_reply=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_contact().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_copy(from_chat_id, message_id, caption=None, parse_mode=None, caption_entities=None, disable_notification=None, reply_to_message_id=None, allow_sending_without_reply=None, reply_markup=None, timeout=None, api_kwargs=None)

Shortcut for:

bot.copy_message(chat_id=update.effective_user.id, *args, **kwargs)

For the documentation of the arguments, please see telegram.Bot.copy_message().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_dice(disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, emoji=None, api_kwargs=None, allow_sending_without_reply=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_dice().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_document(document, filename=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, parse_mode=None, thumb=None, api_kwargs=None, disable_content_type_detection=None, allow_sending_without_reply=None, caption_entities=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_document().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_game(game_short_name, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, api_kwargs=None, allow_sending_without_reply=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_game().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_invoice(title, description, payload, provider_token, start_parameter, currency, prices, photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None, need_email=None, need_shipping_address=None, is_flexible=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, provider_data=None, send_phone_number_to_provider=None, send_email_to_provider=None, timeout=None, api_kwargs=None, allow_sending_without_reply=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_invoice().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_location(latitude=None, longitude=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, location=None, live_period=None, api_kwargs=None, horizontal_accuracy=None, heading=None, proximity_alert_radius=None, allow_sending_without_reply=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_location().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_media_group(media, disable_notification=None, reply_to_message_id=None, timeout=20, api_kwargs=None, allow_sending_without_reply=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_media_group().

Returns

] On success, instance representing the message posted.

Return type

List[telegram.Message

send_message(text, parse_mode=None, disable_web_page_preview=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, api_kwargs=None, allow_sending_without_reply=None, entities=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_message().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_photo(photo, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, parse_mode=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_photo().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_poll(question, options, is_anonymous=True, type='regular', allows_multiple_answers=False, correct_option_id=None, is_closed=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, explanation=None, explanation_parse_mode=None, open_period=None, close_date=None, api_kwargs=None, allow_sending_without_reply=None, explanation_entities=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_poll().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_sticker(sticker, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, api_kwargs=None, allow_sending_without_reply=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_sticker().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_venue(latitude=None, longitude=None, title=None, address=None, foursquare_id=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, venue=None, foursquare_type=None, api_kwargs=None, google_place_id=None, google_place_type=None, allow_sending_without_reply=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_venue().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_video(video, duration=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, width=None, height=None, parse_mode=None, supports_streaming=None, thumb=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_video().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_video_note(video_note, duration=None, length=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, thumb=None, api_kwargs=None, allow_sending_without_reply=None, filename=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_video_note().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

send_voice(voice, duration=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, parse_mode=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None)

Shortcut for:

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

For the documentation of the arguments, please see telegram.Bot.send_voice().

Returns

On success, instance representing the message posted.

Return type

telegram.Message

unpin_all_messages(timeout=None, api_kwargs=None)

Shortcut for:

bot.unpin_all_chat_messages(chat_id=update.effective_user.id,
                            *args,
                            **kwargs)

For the documentation of the arguments, please see telegram.Bot.unpin_all_chat_messages().

Returns

On success, True is returned.

Return type

bool

unpin_message(timeout=None, api_kwargs=None, message_id=None)

Shortcut for:

bot.unpin_chat_message(chat_id=update.effective_user.id,
                       *args,
                       **kwargs)

For the documentation of the arguments, please see telegram.Bot.unpin_chat_message().

Returns

On success, True is returned.

Return type

bool