telegram.User#
- class telegram.User(*args, **kwargs)[source]#
Bases:
telegram.TelegramObjectThis 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
idis equal.- Parameters
first_name (
str) – User’s or bots first name.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 intelegram.Bot.get_merequests.can_read_all_group_messages (
str, optional) –True, if privacy mode is disabled for the bot. Returned only intelegram.Bot.get_merequests.supports_inline_queries (
str, optional) –True, if the bot supports inline queries. Returned only intelegram.Bot.get_merequests.bot (
telegram.Bot, optional) – The Bot to use for instance methods.
- can_join_groups[source]#
Optional.
True, if the bot can be invited to groups. Returned only intelegram.Bot.get_merequests.- Type
- can_read_all_group_messages[source]#
Optional.
True, if privacy mode is disabled for the bot. Returned only intelegram.Bot.get_merequests.- Type
- supports_inline_queries[source]#
Optional.
True, if the bot supports inline queries. Returned only intelegram.Bot.get_merequests.- Type
- async approve_join_request(chat_id, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]#
Shortcut for:
await bot.approve_chat_join_request(user_id=update.effective_user.id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.approve_chat_join_request().New in version 13.8.
- async 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, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None, protect_content=None)[source]#
Shortcut for:
await 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
- async decline_join_request(chat_id, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]#
Shortcut for:
await bot.decline_chat_join_request(user_id=update.effective_user.id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.decline_chat_join_request().New in version 13.8.
- property full_name[source]#
Convenience property. The user’s
first_name, followed by (if available)last_name.- Type
Shortcut for:
await bot.get_chat_menu_button(chat_id=update.effective_user.id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.get_chat_menu_button()...seealso::
set_menu_button()New in version 20.0.
- Returns
On success, the current menu button is returned.
- Return type
- async get_profile_photos(offset=None, limit=100, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]#
Shortcut for:
await 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().
- property link[source]#
Convenience property. If
usernameis available, returns a t.me link of the user.- Type
- mention_button(name=None)[source]#
Shortcut for:
InlineKeyboardButton(text=name, url=f"tg://user?id={update.effective_user.id}")
New in version 13.9.
- mention_markdown(name=None)[source]#
Note
'Markdown'is a legacy mode, retained by Telegram for backward compatibility. You should usemention_markdown_v2()instead.
- property name[source]#
Convenience property. If available, returns the user’s
usernameprefixed with “@”. Ifusernameis not available, returnsfull_name.- Type
- async pin_message(message_id, disable_notification=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]#
Shortcut for:
await 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().
- async send_action(action, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]#
Alias for
send_chat_action
- async 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, read_timeout=None, write_timeout=20, connect_timeout=None, pool_timeout=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None, protect_content=None)[source]#
Shortcut for:
await bot.send_animation(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
- async send_audio(audio, duration=None, performer=None, title=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=20, connect_timeout=None, pool_timeout=None, parse_mode=None, thumb=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None, protect_content=None)[source]#
Shortcut for:
await bot.send_audio(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
- async send_chat_action(action, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]#
Shortcut for:
await bot.send_chat_action(update.effective_user.id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_chat_action().- Returns
On success.
- Return type
- async send_contact(phone_number=None, first_name=None, last_name=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, contact=None, vcard=None, api_kwargs=None, allow_sending_without_reply=None, protect_content=None)[source]#
Shortcut for:
await bot.send_contact(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
- async 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, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None, protect_content=None)[source]#
Shortcut for:
await 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
- async send_dice(disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, emoji=None, api_kwargs=None, allow_sending_without_reply=None, protect_content=None)[source]#
Shortcut for:
await bot.send_dice(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
- async send_document(document, filename=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=20, connect_timeout=None, pool_timeout=None, parse_mode=None, thumb=None, api_kwargs=None, disable_content_type_detection=None, allow_sending_without_reply=None, caption_entities=None, protect_content=None)[source]#
Shortcut for:
await bot.send_document(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
- async send_game(game_short_name, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None, allow_sending_without_reply=None, protect_content=None)[source]#
Shortcut for:
await bot.send_game(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
- async send_invoice(title, description, payload, provider_token, currency, prices, start_parameter=None, 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, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None, allow_sending_without_reply=None, max_tip_amount=None, suggested_tip_amounts=None, protect_content=None)[source]#
Shortcut for:
await bot.send_invoice(update.effective_user.id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_invoice().Warning
As of API 5.2
start_parameteris an optional argument and therefore the order of the arguments had to be changed. Use keyword arguments to make sure that the arguments are passed correctly.Changed in version 13.5: As of Bot API 5.2, the parameter
start_parameteris optional.- Returns
On success, instance representing the message posted.
- Return type
- async send_location(latitude=None, longitude=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, location=None, live_period=None, api_kwargs=None, horizontal_accuracy=None, heading=None, proximity_alert_radius=None, allow_sending_without_reply=None, protect_content=None)[source]#
Shortcut for:
await bot.send_location(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
- async send_media_group(media, disable_notification=None, reply_to_message_id=None, read_timeout=None, write_timeout=20, connect_timeout=None, pool_timeout=None, api_kwargs=None, allow_sending_without_reply=None, protect_content=None)[source]#
Shortcut for:
await bot.send_media_group(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
- async send_message(text, parse_mode=None, disable_web_page_preview=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None, allow_sending_without_reply=None, entities=None, protect_content=None)[source]#
Shortcut for:
await 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
- async send_photo(photo, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=20, connect_timeout=None, pool_timeout=None, parse_mode=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None, protect_content=None)[source]#
Shortcut for:
await bot.send_photo(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
- async send_poll(question, options, is_anonymous=True, type=PollType.REGULAR, allows_multiple_answers=False, correct_option_id=None, is_closed=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_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, protect_content=None)[source]#
Shortcut for:
await bot.send_poll(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
- async send_sticker(sticker, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=20, connect_timeout=None, pool_timeout=None, api_kwargs=None, allow_sending_without_reply=None, protect_content=None)[source]#
Shortcut for:
await bot.send_sticker(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
- async send_venue(latitude=None, longitude=None, title=None, address=None, foursquare_id=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, venue=None, foursquare_type=None, api_kwargs=None, google_place_id=None, google_place_type=None, allow_sending_without_reply=None, protect_content=None)[source]#
Shortcut for:
await bot.send_venue(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
- async send_video(video, duration=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=20, connect_timeout=None, pool_timeout=None, 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, protect_content=None)[source]#
Shortcut for:
await bot.send_video(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
- async send_video_note(video_note, duration=None, length=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=20, connect_timeout=None, pool_timeout=None, thumb=None, api_kwargs=None, allow_sending_without_reply=None, filename=None, protect_content=None)[source]#
Shortcut for:
await bot.send_video_note(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
- async send_voice(voice, duration=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, read_timeout=None, write_timeout=20, connect_timeout=None, pool_timeout=None, parse_mode=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None, protect_content=None)[source]#
Shortcut for:
await bot.send_voice(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
Shortcut for:
await bot.set_chat_menu_button(chat_id=update.effective_chat.id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.set_chat_menu_button()...seealso::
get_menu_button()New in version 20.0.
- async unpin_all_messages(read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]#
Shortcut for:
await 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().
- async unpin_message(read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None, message_id=None)[source]#
Shortcut for:
await 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().