Message
- class aiogram.types.message.Message(conf: Optional[Dict[str, Any]] = None, **kwargs: Any)[source]
Bases:
TelegramObject
This object represents a message.
https://core.telegram.org/bots/api#message
Deserialize object
- Parameters
conf –
kwargs –
- is_forward() bool [source]
Check that the message is forwarded. Only forward_date is required to be in forwarded message.
- Returns
bool
- get_full_command() Optional[Tuple[str, str]] [source]
Split command and args
- Returns
tuple of (command, args)
- parse_entities(as_html=True) str [source]
Text or caption formatted as HTML or Markdown.
- Returns
str
- property from_id: int
User id if sent by user or chat/channel id if sent on behalf of a channel or chat
- Returns
int
- property md_text: str
Text or caption formatted as markdown.
- Returns
str
- property html_text: str
Text or caption formatted as HTML
- Returns
str
- property url: str
Get URL for the message
- Returns
str
- link(text, as_html=True) str [source]
Generate URL for using in text messages with HTML or MD parse mode
- Parameters
text – link label
as_html – generate as HTML
- Returns
str
- async answer(text: String, parse_mode: Optional[String] = None, entities: Optional[List[MessageEntity]] = None, disable_web_page_preview: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Answer to this message
- Parameters
text (
base.String
) – Text of the message to be sentparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modedisable_web_page_preview (
typing.Optional[base.Boolean]
) – Disables link previews for links in this messagedisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned
- Return type
types.Message
- async answer_photo(photo: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send photos.
Source: https://core.telegram.org/bots/api#sendphoto
- Parameters
photo (
typing.Union[base.InputFile, base.String]
) – Photo to sendcaption (
typing.Optional[base.String]
) – Photo caption (may also be used when resending photos by file_id), 0-1024 charactersparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.caption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modedisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned
- Return type
types.Message
- async answer_audio(audio: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[Integer] = None, performer: Optional[String] = None, title: Optional[String] = None, thumb: Optional[Union[InputFile, String]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format.
For sending voice messages, use the sendVoice method instead.
Source: https://core.telegram.org/bots/api#sendaudio
- Parameters
audio (
typing.Union[base.InputFile, base.String]
) – Audio file to send.caption (
typing.Optional[base.String]
) – Audio caption, 0-1024 characters after entities parsingparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.caption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modeduration (
typing.Optional[base.Integer]
) – Duration of the audio in secondsperformer (
typing.Optional[base.String]
) – Performertitle (
typing.Optional[base.String]
) – Track namethumb (
typing.Union[typing.Union[base.InputFile, base.String], None]
) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.disable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async answer_animation(animation: Union[InputFile, String], duration: Optional[Integer] = None, width: Optional[Integer] = None, height: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
Source https://core.telegram.org/bots/api#sendanimation
- Parameters
animation (
typing.Union[base.InputFile, base.String]
) – Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-dataduration (
typing.Optional[base.Integer]
) – Duration of sent animation in secondswidth (
typing.Optional[base.Integer]
) – Animation widthheight (
typing.Optional[base.Integer]
) – Animation heightthumb (
typing.Union[typing.Union[base.InputFile, base.String], None]
) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.caption (
typing.Optional[base.String]
) – Animation caption (may also be used when resending animation by file_id), 0-1024 charactersparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captioncaption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modedisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned
- Return type
types.Message
- async answer_document(document: Union[InputFile, String], thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_content_type_detection: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
Source: https://core.telegram.org/bots/api#senddocument
- Parameters
document (
typing.Union[base.InputFile, base.String]
) – File to sendthumb (
typing.Union[base.InputFile, base.String, None]
) – Thumbnail of the file sentcaption (
typing.Optional[base.String]
) – Document caption (may also be used when resending documents by file_id), 0-1024 charactersdisable_content_type_detection (
typing.Optional[base.Boolean]
) – Disables automatic server-side content type detection for files uploaded using multipart/form-dataparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.caption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modedisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
typing.Optional[base.Boolean]
) – True if the message is a reply
- Returns
On success, the sent Message is returned
- Return type
types.Message
- async answer_video(video: Union[InputFile, String], duration: Optional[Integer] = None, width: Optional[Integer] = None, height: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, supports_streaming: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
Source: https://core.telegram.org/bots/api#sendvideo
- Parameters
video (
typing.Union[base.InputFile, base.String]
) – Video to send.duration (
typing.Optional[base.Integer]
) – Duration of sent video in secondswidth (
typing.Optional[base.Integer]
) – Video widthheight (
typing.Optional[base.Integer]
) – Video heightthumb (
typing.Union[base.InputFile, base.String, None]
) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.caption (
typing.Optional[base.String]
) – Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsingparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captioncaption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modesupports_streaming (
typing.Optional[base.Boolean]
) – Pass True, if the uploaded video is suitable for streamingdisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async answer_voice(voice: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.
For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document).
Source: https://core.telegram.org/bots/api#sendvoice
- Parameters
voice (
typing.Union[base.InputFile, base.String]
) – Audio file to send.caption (
typing.Optional[base.String]
) – Voice message caption, 0-1024 characters after entities parsingparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captioncaption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modeduration (
typing.Optional[base.Integer]
) – Duration of the voice message in secondsdisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async answer_video_note(video_note: Union[InputFile, String], duration: Optional[Integer] = None, length: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages.
Source: https://core.telegram.org/bots/api#sendvideonote
- Parameters
video_note (
typing.Union[base.InputFile, base.String]
) – Video note to send.duration (
typing.Optional[base.Integer]
) – Duration of sent video in secondslength (
typing.Optional[base.Integer]
) – Video width and heightthumb (
typing.Union[typing.Union[base.InputFile, base.String], None]
) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.disable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async answer_media_group(media: Union[MediaGroup, List], disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply: Boolean = False) List[Message] [source]
Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only group in an album with messages of the same type. On success, an array of Messages that were sent is returned.
Source: https://core.telegram.org/bots/api#sendmediagroup
- Parameters
media (
typing.Union[types.MediaGroup, typing.List]
) – A JSON-serialized array describing photos and videos to be sentdisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, an array of the sent Messages is returned.
- Return type
List[types.Message]
- async answer_location(latitude: Float, longitude: Float, live_period: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, horizontal_accuracy: Optional[Float] = None, heading: Optional[Integer] = None, proximity_alert_radius: Optional[Integer] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send point on the map.
Source: https://core.telegram.org/bots/api#sendlocation
- Parameters
latitude (
base.Float
) – Latitude of the locationlongitude (
base.Float
) – Longitude of the locationhorizontal_accuracy (
typing.Optional[base.Float]
) – The radius of uncertainty for the location, measured in meters; 0-1500live_period (
typing.Optional[base.Integer]
) – Period in seconds for which the location will be updatedheading (
typing.Optional[base.Integer]
) – For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.proximity_alert_radius (
typing.Optional[base.Integer]
) – For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.disable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async answer_venue(latitude: Float, longitude: Float, title: String, address: String, foursquare_id: Optional[String] = None, foursquare_type: Optional[String] = None, google_place_id: Optional[String] = None, google_place_type: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send information about a venue.
Source: https://core.telegram.org/bots/api#sendvenue
- Parameters
latitude (
base.Float
) – Latitude of the venuelongitude (
base.Float
) – Longitude of the venuetitle (
base.String
) – Name of the venueaddress (
base.String
) – Address of the venuefoursquare_id (
typing.Optional[base.String]
) – Foursquare identifier of the venuefoursquare_type (
typing.Optional[base.String]
) – Foursquare type of the venue, if knowngoogle_place_id (
typing.Optional[base.String]
) – Google Places identifier of the venuegoogle_place_type (
typing.Optional[base.String]
) – Google Places type of the venue. See supported types: https://developers.google.com/places/web-service/supported_typesdisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async answer_contact(phone_number: String, first_name: String, last_name: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send phone contacts.
Source: https://core.telegram.org/bots/api#sendcontact
- Parameters
phone_number (
base.String
) – Contact’s phone numberfirst_name (
base.String
) – Contact’s first namelast_name (
typing.Optional[base.String]
) – Contact’s last namedisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async answer_sticker(sticker: Union[InputFile, String], disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send .webp stickers.
Source: https://core.telegram.org/bots/api#sendsticker
- Parameters
sticker (
typing.Union[base.InputFile, base.String]
) – Sticker to send.disable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async answer_poll(question: String, options: List[String], is_anonymous: Optional[Boolean] = None, type: Optional[String] = None, allows_multiple_answers: Optional[Boolean] = None, correct_option_id: Optional[Integer] = None, explanation: Optional[String] = None, explanation_parse_mode: Optional[String] = None, explanation_entities: Optional[List[MessageEntity]] = None, open_period: Optional[Integer] = None, close_date: Optional[Union[Integer, datetime, timedelta]] = None, is_closed: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send a native poll. On success, the sent Message is returned.
Source: https://core.telegram.org/bots/api#sendpoll
- Parameters
question (
base.String
) – Poll question, 1-255 charactersoptions (
typing.List[base.String]
) – List of answer options, 2-10 strings 1-100 characters eachis_anonymous (
typing.Optional[base.Boolean]
) – True, if the poll needs to be anonymous, defaults to Truetype (
typing.Optional[base.String]
) – Poll type, “quiz” or “regular”, defaults to “regular”allows_multiple_answers (
typing.Optional[base.Boolean]
) – True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to Falsecorrect_option_id (
typing.Optional[base.Integer]
) – 0-based identifier of the correct answer option, required for polls in quiz modeexplanation (
typing.Optional[base.String]
) – Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsingexplanation_parse_mode (
typing.Optional[base.String]
) – Mode for parsing entities in the explanation. See formatting options for more details.explanation_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modeopen_period (
typing.Optional[base.Integer]
) – Amount of time in seconds the poll will be active after creation, 5-600. Can’t be used together with close_date.close_date (
typing.Union[base.Integer, datetime.datetime, datetime.timedelta, None]
) – Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can’t be used together with open_period.is_closed (
typing.Optional[base.Boolean]
) – Pass True, if the poll needs to be immediately closeddisable_notification (
typing.Optional[Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned
- Return type
types.Message
- async answer_dice(emoji: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message [source]
Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
Source: https://core.telegram.org/bots/api#senddice
- Parameters
emoji (
typing.Optional[base.String]
) – Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, or “🎰”. Dice can have values 1-6 for “🎲” and “🎯”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”disable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async answer_chat_action(action: String, message_thread_id: Optional[Integer] = None) Boolean [source]
Use this method when you need to tell the user that something is happening on the bot’s side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
Source: https://core.telegram.org/bots/api#sendchataction
- Parameters
action (
base.String
) – Type of action to broadcastmessage_thread_id (
typing.Optional[base.Integer]
) – Unique identifier for the target message thread; supergroups only
- Returns
Returns True on success
- Return type
base.Boolean
- async reply(text: String, parse_mode: Optional[String] = None, entities: Optional[List[MessageEntity]] = None, disable_web_page_preview: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Reply to this message
- Parameters
text (
base.String
) – Text of the message to be sentparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modedisable_web_page_preview (
typing.Optional[base.Boolean]
) – Disables link previews for links in this messagedisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned
- Return type
types.Message
- async reply_photo(photo: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send photos.
Source: https://core.telegram.org/bots/api#sendphoto
- Parameters
photo (
typing.Union[base.InputFile, base.String]
) – Photo to sendcaption (
typing.Optional[base.String]
) – Photo caption (may also be used when resending photos by file_id), 0-1024 charactersparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.caption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modedisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned
- Return type
types.Message
- async reply_audio(audio: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[Integer] = None, performer: Optional[String] = None, title: Optional[String] = None, thumb: Optional[Union[InputFile, String]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format.
For sending voice messages, use the sendVoice method instead.
Source: https://core.telegram.org/bots/api#sendaudio
- Parameters
audio (
typing.Union[base.InputFile, base.String]
) – Audio file to send.caption (
typing.Optional[base.String]
) – Audio caption, 0-1024 characters after entities parsingparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.caption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modeduration (
typing.Optional[base.Integer]
) – Duration of the audio in secondsperformer (
typing.Optional[base.String]
) – Performertitle (
typing.Optional[base.String]
) – Track namethumb (
typing.Union[typing.Union[base.InputFile, base.String], None]
) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.disable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async reply_animation(animation: Union[InputFile, String], duration: Optional[Integer] = None, width: Optional[Integer] = None, height: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
Source https://core.telegram.org/bots/api#sendanimation
- Parameters
animation (
typing.Union[base.InputFile, base.String]
) – Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-dataduration (
typing.Optional[base.Integer]
) – Duration of sent animation in secondswidth (
typing.Optional[base.Integer]
) – Animation widthheight (
typing.Optional[base.Integer]
) – Animation heightthumb (
typing.Union[typing.Union[base.InputFile, base.String], None]
) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.caption (
typing.Optional[base.String]
) – Animation caption (may also be used when resending animation by file_id), 0-1024 charactersparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captioncaption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modedisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned
- Return type
types.Message
- async reply_document(document: Union[InputFile, String], thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_content_type_detection: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
Source: https://core.telegram.org/bots/api#senddocument
- Parameters
document (
typing.Union[base.InputFile, base.String]
) – File to sendthumb (
typing.Union[base.InputFile, base.String, None]
) – Thumbnail of the file sentcaption (
typing.Optional[base.String]
) – Document caption (may also be used when resending documents by file_id), 0-1024 charactersdisable_content_type_detection (
typing.Optional[base.Boolean]
) – Disables automatic server-side content type detection for files uploaded using multipart/form-dataparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.caption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modedisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
typing.Optional[base.Boolean]
) – True if the message is a reply
- Returns
On success, the sent Message is returned
- Return type
types.Message
- async reply_video(video: Union[InputFile, String], duration: Optional[Integer] = None, width: Optional[Integer] = None, height: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, supports_streaming: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
Source: https://core.telegram.org/bots/api#sendvideo
- Parameters
video (
typing.Union[base.InputFile, base.String]
) – Video to send.duration (
typing.Optional[base.Integer]
) – Duration of sent video in secondswidth (
typing.Optional[base.Integer]
) – Video widthheight (
typing.Optional[base.Integer]
) – Video heightthumb (
typing.Union[base.InputFile, base.String, None]
) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.caption (
typing.Optional[base.String]
) – Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsingparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captioncaption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modesupports_streaming (
typing.Optional[base.Boolean]
) – Pass True, if the uploaded video is suitable for streamingdisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async reply_voice(voice: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.
For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document).
Source: https://core.telegram.org/bots/api#sendvoice
- Parameters
voice (
typing.Union[base.InputFile, base.String]
) – Audio file to send.caption (
typing.Optional[base.String]
) – Voice message caption, 0-1024 characters after entities parsingparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captioncaption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modeduration (
typing.Optional[base.Integer]
) – Duration of the voice message in secondsdisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async reply_video_note(video_note: Union[InputFile, String], duration: Optional[Integer] = None, length: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages.
Source: https://core.telegram.org/bots/api#sendvideonote
- Parameters
video_note (
typing.Union[base.InputFile, base.String]
) – Video note to send.duration (
typing.Optional[base.Integer]
) – Duration of sent video in secondslength (
typing.Optional[base.Integer]
) – Video width and heightthumb (
typing.Union[typing.Union[base.InputFile, base.String], None]
) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.disable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (:obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] `) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user
reply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async reply_media_group(media: Union[MediaGroup, List], disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply: Boolean = True) List[Message] [source]
Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only group in an album with messages of the same type. On success, an array of Messages that were sent is returned.
Source: https://core.telegram.org/bots/api#sendmediagroup
- Parameters
media (
typing.Union[types.MediaGroup, typing.List]
) – A JSON-serialized array describing photos and videos to be sentdisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, an array of the sent Messages is returned.
- Return type
List[types.Message]
- async reply_location(latitude: Float, longitude: Float, live_period: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, horizontal_accuracy: Optional[Float] = None, heading: Optional[Integer] = None, proximity_alert_radius: Optional[Integer] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send point on the map.
Source: https://core.telegram.org/bots/api#sendlocation
- Parameters
latitude (
base.Float
) – Latitude of the locationlongitude (
base.Float
) – Longitude of the locationhorizontal_accuracy (
typing.Optional[base.Float]
) – The radius of uncertainty for the location, measured in meters; 0-1500live_period (
typing.Optional[base.Integer]
) – Period in seconds for which the location will be updatedheading (
typing.Optional[base.Integer]
) – For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.proximity_alert_radius (
typing.Optional[base.Integer]
) – For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.disable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async reply_venue(latitude: Float, longitude: Float, title: String, address: String, foursquare_id: Optional[String] = None, foursquare_type: Optional[String] = None, google_place_id: Optional[String] = None, google_place_type: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send information about a venue.
Source: https://core.telegram.org/bots/api#sendvenue
- Parameters
latitude (
base.Float
) – Latitude of the venuelongitude (
base.Float
) – Longitude of the venuetitle (
base.String
) – Name of the venueaddress (
base.String
) – Address of the venuefoursquare_id (
typing.Optional[base.String]
) – Foursquare identifier of the venuefoursquare_type (
typing.Optional[base.String]
) – Foursquare type of the venue, if knowngoogle_place_id (
typing.Optional[base.String]
) – Google Places identifier of the venuegoogle_place_type (
typing.Optional[base.String]
) – Google Places type of the venue. See supported types: https://developers.google.com/places/web-service/supported_typesdisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async reply_contact(phone_number: String, first_name: String, last_name: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send phone contacts.
Source: https://core.telegram.org/bots/api#sendcontact
- Parameters
phone_number (
base.String
) – Contact’s phone numberfirst_name (
base.String
) – Contact’s first namelast_name (
typing.Optional[base.String]
) – Contact’s last namedisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async reply_poll(question: String, options: List[String], is_anonymous: Optional[Boolean] = None, type: Optional[String] = None, allows_multiple_answers: Optional[Boolean] = None, correct_option_id: Optional[Integer] = None, explanation: Optional[String] = None, explanation_parse_mode: Optional[String] = None, explanation_entities: Optional[List[MessageEntity]] = None, open_period: Optional[Integer] = None, close_date: Optional[Union[Integer, datetime, timedelta]] = None, is_closed: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send a native poll. On success, the sent Message is returned.
Source: https://core.telegram.org/bots/api#sendpoll
- Parameters
question (
base.String
) – Poll question, 1-255 charactersoptions (
typing.List[base.String]
) – List of answer options, 2-10 strings 1-100 characters eachis_anonymous (
typing.Optional[base.Boolean]
) – True, if the poll needs to be anonymous, defaults to Truetype (
typing.Optional[base.String]
) – Poll type, “quiz” or “regular”, defaults to “regular”allows_multiple_answers (
typing.Optional[base.Boolean]
) – True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to Falsecorrect_option_id (
typing.Optional[base.Integer]
) – 0-based identifier of the correct answer option, required for polls in quiz modeexplanation (
typing.Optional[base.String]
) – Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsingexplanation_parse_mode (
typing.Optional[base.String]
) – Mode for parsing entities in the explanation. See formatting options for more details.explanation_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modeopen_period (
typing.Optional[base.Integer]
) – Amount of time in seconds the poll will be active after creation, 5-600. Can’t be used together with close_date.close_date (
typing.Union[base.Integer, datetime.datetime, datetime.timedelta, None]
) – Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can’t be used together with open_period.is_closed (
typing.Optional[base.Boolean]
) – Pass True, if the poll needs to be immediately closeddisable_notification (
typing.Optional[Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned
- Return type
types.Message
- async reply_sticker(sticker: Union[InputFile, String], disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send .webp stickers.
Source: https://core.telegram.org/bots/api#sendsticker
- Parameters
sticker (
typing.Union[base.InputFile, base.String]
) – Sticker to send.disable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no sound.protect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async reply_dice(emoji: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message [source]
Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
Source: https://core.telegram.org/bots/api#senddice
- Parameters
emoji (
typing.Optional[base.String]
) – Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, or “🎰”. Dice can have values 1-6 for “🎲” and “🎯”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”disable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of sent messages from forwarding and savingallow_sending_without_reply (
typing.Optional[base.Boolean]
) – Pass True, if the message should be sent even if the specified replied-to message is not foundreply_markup (
typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]
) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the userreply (
base.Boolean
) – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
- async forward(chat_id: Union[Integer, String], message_thread_id: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None) Message [source]
Forward this message
Source: https://core.telegram.org/bots/api#forwardmessage
- Parameters
chat_id (
typing.Union[base.Integer, base.String]
) – Unique identifier for the target chat or username of the target channelmessage_thread_id (
typing.Optional[base.Integer]
) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups onlydisable_notification (
typing.Optional[base.Boolean]
) – Sends the message silently. Users will receive a notification with no soundprotect_content (
typing.Optional[base.Boolean]
) – Protects the contents of the forwarded message from forwarding and saving
- Returns
On success, the sent Message is returned
- Return type
types.Message
- async edit_text(text: String, parse_mode: Optional[String] = None, entities: Optional[List[MessageEntity]] = None, disable_web_page_preview: Optional[Boolean] = None, reply_markup: Optional[InlineKeyboardMarkup] = None) Union[Message, Boolean] [source]
Use this method to edit text and game messages sent by the bot or via the bot (for inline bots).
Source: https://core.telegram.org/bots/api#editmessagetext
- Parameters
text (
base.String
) – New text of the messageparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modedisable_web_page_preview (
typing.Optional[base.Boolean]
) – Disables link previews for links in this messagereply_markup (
typing.Optional[types.InlineKeyboardMarkup]
) – A JSON-serialized object for an inline keyboard.
- Returns
On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
- Return type
typing.Union[types.Message, base.Boolean]
Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).
Source: https://core.telegram.org/bots/api#editmessagecaption
- Parameters
caption (
typing.Optional[base.String]
) – New caption of the messageparse_mode (
typing.Optional[base.String]
) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.caption_entities (
typing.Optional[typing.List[MessageEntity]]
) – List of special entities that appear in message text, which can be specified instead of parse_modereply_markup (
typing.Optional[types.InlineKeyboardMarkup]
) – A JSON-serialized object for an inline keyboard
- Returns
On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
- Return type
typing.Union[types.Message, base.Boolean]
- async edit_media(media: InputMedia, reply_markup: Optional[InlineKeyboardMarkup] = None) Union[Message, Boolean] [source]
Use this method to edit audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can’t be uploaded. Use previously uploaded file via its file_id or specify a URL.
On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.
Source https://core.telegram.org/bots/api#editmessagemedia
- Parameters
media (
types.InputMedia
) – A JSON-serialized object for a new media content of the messagereply_markup (
typing.Optional[types.InlineKeyboardMarkup]
) – A JSON-serialized object for a new inline keyboard
- Returns
On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned
- Return type
typing.Union[types.Message, base.Boolean]
- async edit_reply_markup(reply_markup: Optional[InlineKeyboardMarkup] = None) Union[Message, Boolean] [source]
Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
Source: https://core.telegram.org/bots/api#editmessagereplymarkup
- Parameters
reply_markup (
typing.Optional[types.InlineKeyboardMarkup]
) – A JSON-serialized object for an inline keyboard- Returns
On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
- Return type
typing.Union[types.Message, base.Boolean]
- async delete_reply_markup() Union[Message, Boolean] [source]
Use this method to delete reply markup of messages sent by the bot or via the bot (for inline bots).
- Returns
On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
- Return type
typing.Union[types.Message, base.Boolean]
- async edit_live_location(latitude: Float, longitude: Float, reply_markup: Optional[InlineKeyboardMarkup] = None) Union[Message, Boolean] [source]
Use this method to edit live location messages sent by the bot or via the bot (for inline bots). A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation.
Source: https://core.telegram.org/bots/api#editmessagelivelocation
- Parameters
latitude (
base.Float
) – Latitude of new locationlongitude (
base.Float
) – Longitude of new locationreply_markup (
typing.Optional[types.InlineKeyboardMarkup]
) – A JSON-serialized object for a new inline keyboard.
- Returns
On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.
- Return type
typing.Union[types.Message, base.Boolean]
- async stop_live_location(reply_markup: Optional[InlineKeyboardMarkup] = None) Union[Message, Boolean] [source]
Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before live_period expires.
Source: https://core.telegram.org/bots/api#stopmessagelivelocation
- Parameters
reply_markup (
typing.Optional[types.InlineKeyboardMarkup]
) – A JSON-serialized object for a new inline keyboard.- Returns
On success, if the message was sent by the bot, the sent Message is returned, otherwise True is returned.
- Return type
typing.Union[types.Message, base.Boolean]
- async delete() Boolean [source]
Use this method to delete a message, including service messages, with the following limitations: - A message can only be deleted if it was sent less than 48 hours ago. - Bots can delete outgoing messages in private chats, groups, and supergroups. - Bots can delete incoming messages in private chats. - Bots granted can_post_messages permissions can delete outgoing messages in channels. - If the bot is an administrator of a group, it can delete any message there. - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
Source: https://core.telegram.org/bots/api#deletemessage
- Returns
Returns True on success
- Return type
base.Boolean
- async pin(disable_notification: Optional[Boolean] = None) Boolean [source]
Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in a supergroup or ‘can_edit_messages’ admin right in a channel. Returns True on success.
Source: https://core.telegram.org/bots/api#pinchatmessage
- Parameters
disable_notification (
typing.Optional[base.Boolean]
) – Pass True, if it is not necessary to send a notification to all group members about the new pinned message- Returns
Returns True on success
- Return type
base.Boolean
- async unpin() Boolean [source]
Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in a supergroup or ‘can_edit_messages’ admin right in a channel. Returns True on success.
Source: https://core.telegram.org/bots/api#unpinchatmessage
- Returns
Returns True on success
- Return type
base.Boolean
- async send_copy(chat_id: Union[str, int], message_thread_id: Optional[Integer] = None, disable_notification: Optional[bool] = None, protect_content: Optional[Boolean] = None, disable_web_page_preview: Optional[bool] = None, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup]] = None) Message [source]
Send copy of current message
- Parameters
chat_id –
message_thread_id –
disable_notification –
protect_content –
disable_web_page_preview – for text messages only
reply_to_message_id –
allow_sending_without_reply –
reply_markup –
- Returns
ContentType
- class aiogram.types.message.ContentType[source]
Bases:
Helper
List of message content types
WARNING: Single elements
- Key
TEXT
- Key
AUDIO
- Key
DOCUMENT
- Key
GAME
- Key
PHOTO
- Key
STICKER
- Key
VIDEO
- Key
VIDEO_NOTE
- Key
VOICE
- Key
CONTACT
- Key
LOCATION
- Key
VENUE
- Key
POLL
- Key
DICE
- Key
NEW_CHAT_MEMBERS
- Key
LEFT_CHAT_MEMBER
- Key
INVOICE
- Key
SUCCESSFUL_PAYMENT
- Key
CONNECTED_WEBSITE
- Key
MIGRATE_TO_CHAT_ID
- Key
MIGRATE_FROM_CHAT_ID
- Key
UNKNOWN
- Key
ANY
ContentTypes
- class aiogram.types.message.ContentTypes[source]
Bases:
Helper
List of message content types
WARNING: List elements.
- Key
TEXT
- Key
AUDIO
- Key
DOCUMENT
- Key
GAME
- Key
PHOTO
- Key
STICKER
- Key
VIDEO
- Key
VIDEO_NOTE
- Key
VOICE
- Key
CONTACT
- Key
LOCATION
- Key
VENUE
- Key
POLL
- Key
DICE
- Key
NEW_CHAT_MEMBERS
- Key
LEFT_CHAT_MEMBER
- Key
INVOICE
- Key
SUCCESSFUL_PAYMENT
- Key
CONNECTED_WEBSITE
- Key
MIGRATE_TO_CHAT_ID
- Key
MIGRATE_FROM_CHAT_ID
- Key
UNKNOWN
- Key
ANY