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.

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: Union[int, str], message_id: Union[str, int], caption: str = None, parse_mode: str = None, caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, allow_sending_without_reply: bool = False, reply_markup: ReplyMarkup = None, timeout: float = None, api_kwargs: Dict[str, Any] = None) → MessageId

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
full_name

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

Type:str
get_profile_photos(offset: int = None, limit: int = 100, timeout: float = None, api_kwargs: Dict[str, Any] = None) → Optional[UserProfilePhotos]

Shortcut for:

bot.send_message(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: 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
pin_message(message_id: Union[str, int], disable_notification: bool = None, timeout: float = None, api_kwargs: Dict[str, Any] = None) → bool

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: str, timeout: float = None, api_kwargs: Dict[str, Any] = None) → bool

Alias for send_chat_action

send_animation(animation: Union[str, bytes, IO, InputFile, pathlib.Path, Animation], duration: int = None, width: int = None, height: int = None, thumb: Union[str, bytes, IO, InputFile, pathlib.Path] = None, caption: str = None, parse_mode: str = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = 20, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None, caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None, filename: str = None) → Message

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: Union[str, bytes, IO, InputFile, pathlib.Path, Audio], duration: int = None, performer: str = None, title: str = None, caption: str = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = 20, parse_mode: str = None, thumb: Union[str, bytes, IO, InputFile, pathlib.Path] = None, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None, caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None, filename: str = None) → Message

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: str, timeout: float = None, api_kwargs: Dict[str, Any] = None) → bool

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: str = None, first_name: str = None, last_name: str = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = None, contact: Contact = None, vcard: str = None, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None) → Message

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: Union[str, int], message_id: Union[str, int], caption: str = None, parse_mode: str = None, caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, allow_sending_without_reply: bool = False, reply_markup: ReplyMarkup = None, timeout: float = None, api_kwargs: Dict[str, Any] = None) → MessageId

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: bool = None, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = None, emoji: str = None, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None) → Message

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: Union[str, bytes, IO, InputFile, pathlib.Path, Document], filename: str = None, caption: str = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = 20, parse_mode: str = None, thumb: Union[str, bytes, IO, InputFile, pathlib.Path] = None, api_kwargs: Dict[str, Any] = None, disable_content_type_detection: bool = None, allow_sending_without_reply: bool = None, caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None) → Message

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: str, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: InlineKeyboardMarkup = None, timeout: float = None, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None) → Message

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: str, description: str, payload: str, provider_token: str, start_parameter: str, currency: str, prices: List[LabeledPrice], photo_url: str = None, photo_size: int = None, photo_width: int = None, photo_height: int = None, need_name: bool = None, need_phone_number: bool = None, need_email: bool = None, need_shipping_address: bool = None, is_flexible: bool = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: InlineKeyboardMarkup = None, provider_data: Union[str, object] = None, send_phone_number_to_provider: bool = None, send_email_to_provider: bool = None, timeout: float = None, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None) → Message

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: float = None, longitude: float = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = None, location: Location = None, live_period: int = None, api_kwargs: Dict[str, Any] = None, horizontal_accuracy: float = None, heading: int = None, proximity_alert_radius: int = None, allow_sending_without_reply: bool = None) → Message

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: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]], disable_notification: bool = None, reply_to_message_id: Union[int, str] = None, timeout: float = 20, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None) → List[Message]

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: str, parse_mode: str = None, disable_web_page_preview: bool = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = None, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None, entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None) → Message

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: Union[str, bytes, IO, InputFile, pathlib.Path, PhotoSize], caption: str = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = 20, parse_mode: str = None, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None, caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None, filename: str = None) → Message

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: str, options: List[str], is_anonymous: bool = True, type: str = 'regular', allows_multiple_answers: bool = False, correct_option_id: int = None, is_closed: bool = None, disable_notification: bool = None, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = None, explanation: str = None, explanation_parse_mode: Union[str, telegram.utils.helpers.DefaultValue, None] = <telegram.utils.helpers.DefaultValue object>, open_period: int = None, close_date: Union[int, datetime.datetime] = None, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None, explanation_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None) → Message

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: Union[str, bytes, IO, InputFile, pathlib.Path, Sticker], disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = 20, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None) → Message

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: float = None, longitude: float = None, title: str = None, address: str = None, foursquare_id: str = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = None, venue: Venue = None, foursquare_type: str = None, api_kwargs: Dict[str, Any] = None, google_place_id: str = None, google_place_type: str = None, allow_sending_without_reply: bool = None) → Message

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: Union[str, bytes, IO, InputFile, pathlib.Path, Video], duration: int = None, caption: str = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = 20, width: int = None, height: int = None, parse_mode: str = None, supports_streaming: bool = None, thumb: Union[str, bytes, IO, InputFile, pathlib.Path] = None, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None, caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None, filename: str = None) → Message

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: Union[str, bytes, IO, InputFile, pathlib.Path, VideoNote], duration: int = None, length: int = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = 20, thumb: Union[str, bytes, IO, InputFile, pathlib.Path] = None, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None, filename: str = None) → Message

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: Union[str, bytes, IO, InputFile, pathlib.Path, Voice], duration: int = None, caption: str = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: ReplyMarkup = None, timeout: float = 20, parse_mode: str = None, api_kwargs: Dict[str, Any] = None, allow_sending_without_reply: bool = None, caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None, filename: str = None) → Message

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: float = None, api_kwargs: Dict[str, Any] = None) → bool

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: float = None, api_kwargs: Dict[str, Any] = None, message_id: Union[str, int] = None) → bool

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