Message¶
-
class
aiogram.types.message.Message(conf=None, **kwargs)[source]¶ Bases:
aiogram.types.base.TelegramObjectThis object represents a message.
https://core.telegram.org/bots/api#message
Deserialize object
- Parameters
conf –
kwargs –
-
property
md_text¶ Text or caption formatted as markdown.
- Returns
str
-
property
html_text¶ Text or caption formatted as HTML
- Returns
str
-
property
url¶ 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, disable_web_page_preview: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.Message[source]¶ Answer to this message
- Parameters
text (
base.String) – Text of the message to be sentparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.disable_web_page_preview (
typing.Union[base.Boolean, None]) – Disables link previews for links in this messagedisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no soundreply_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, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.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.Union[base.String, None]) – Photo caption (may also be used when resending photos by file_id), 0-1024 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.disable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no soundreply_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, duration: Optional[Integer] = None, performer: Optional[String] = None, title: Optional[String] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.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.Union[base.String, None]) – Audio caption, 0-200 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.duration (
typing.Union[base.Integer, None]) – Duration of the audio in secondsperformer (
typing.Union[base.String, None]) – Performertitle (
typing.Union[base.String, None]) – Track namedisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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: Union[InputFile, String, None] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.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.Union[base.Integer, None]) – Duration of sent animation in secondswidth (
typing.Union[base.Integer, None]) – Animation widthheight (
typing.Union[base.Integer, None]) – 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 90.caption (
typing.Union[base.String, None]) – Animation caption (may also be used when resending animation by file_id), 0-1024 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captiondisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no soundreply_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 – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned
- Return type
types.Message
-
async
answer_document(document: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.Message[source]¶ Use this method to send general files.
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 send.caption (
typing.Union[base.String, None]) – Document caption (may also be used when resending documents by file_id), 0-200 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captiondisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – fill ‘reply_to_message_id’
- 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, caption: Optional[String] = None, parse_mode: Optional[String] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.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.Union[base.Integer, None]) – Duration of sent video in secondswidth (
typing.Union[base.Integer, None]) – Video widthheight (
typing.Union[base.Integer, None]) – Video heightcaption (
typing.Union[base.String, None]) – Video caption (may also be used when resending videos by file_id), 0-200 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captiondisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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, duration: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.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.Union[base.String, None]) – Voice message caption, 0-200 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captionduration (
typing.Union[base.Integer, None]) – Duration of the voice message in secondsdisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.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.Union[base.Integer, None]) – Duration of sent video in secondslength (
typing.Union[base.Integer, None]) – Video width and heightdisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
-
async
answer_media_group(media: Union[aiogram.types.input_media.MediaGroup, List], disable_notification: Optional[Boolean] = None, reply: Boolean = False) → List[aiogram.types.message.Message][source]¶ Use this method to send a group of photos or videos as an album.
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.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply – fill ‘reply_to_message_id’
- Returns
On success, an array of the sent Messages is returned.
- Return type
typing.List[types.Message]
-
async
answer_location(latitude: Float, longitude: Float, live_period: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.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 locationlive_period (
typing.Union[base.Integer, None]) – Period in seconds for which the location will be updateddisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.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.Union[base.String, None]) – Foursquare identifier of the venuedisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.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.Union[base.String, None]) – Contact’s last namedisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = False) → aiogram.types.message.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.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
-
async
reply(text: String, parse_mode: Optional[String] = None, disable_web_page_preview: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.Message[source]¶ Reply to this message
- Parameters
text (
base.String) – Text of the message to be sentparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.disable_web_page_preview (
typing.Union[base.Boolean, None]) – Disables link previews for links in this messagedisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no soundreply_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, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.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.Union[base.String, None]) – Photo caption (may also be used when resending photos by file_id), 0-1024 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.disable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no soundreply_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, duration: Optional[Integer] = None, performer: Optional[String] = None, title: Optional[String] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.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.Union[base.String, None]) – Audio caption, 0-200 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.duration (
typing.Union[base.Integer, None]) – Duration of the audio in secondsperformer (
typing.Union[base.String, None]) – Performertitle (
typing.Union[base.String, None]) – Track namedisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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: Union[InputFile, String, None] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.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.Union[base.Integer, None]) – Duration of sent animation in secondswidth (
typing.Union[base.Integer, None]) – Animation widthheight (
typing.Union[base.Integer, None]) – 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 90.caption (
typing.Union[base.String, None]) – Animation caption (may also be used when resending animation by file_id), 0-1024 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captiondisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no soundreply_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 – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned
- Return type
types.Message
-
async
reply_document(document: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.Message[source]¶ Use this method to send general files.
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 send.caption (
typing.Union[base.String, None]) – Document caption (may also be used when resending documents by file_id), 0-200 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captiondisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – fill ‘reply_to_message_id’
- 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, caption: Optional[String] = None, parse_mode: Optional[String] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.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.Union[base.Integer, None]) – Duration of sent video in secondswidth (
typing.Union[base.Integer, None]) – Video widthheight (
typing.Union[base.Integer, None]) – Video heightcaption (
typing.Union[base.String, None]) – Video caption (may also be used when resending videos by file_id), 0-200 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captiondisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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, duration: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.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.Union[base.String, None]) – Voice message caption, 0-200 charactersparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media captionduration (
typing.Union[base.Integer, None]) – Duration of the voice message in secondsdisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.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.Union[base.Integer, None]) – Duration of sent video in secondslength (
typing.Union[base.Integer, None]) – Video width and heightdisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
-
async
reply_media_group(media: Union[aiogram.types.input_media.MediaGroup, List], disable_notification: Optional[Boolean] = None, reply: Boolean = True) → List[aiogram.types.message.Message][source]¶ Use this method to send a group of photos or videos as an album.
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.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply – fill ‘reply_to_message_id’
- Returns
On success, an array of the sent Messages is returned.
- Return type
typing.List[types.Message]
-
async
reply_location(latitude: Float, longitude: Float, live_period: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.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 locationlive_period (
typing.Union[base.Integer, None]) – Period in seconds for which the location will be updateddisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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, disable_notification: Optional[Boolean] = None, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.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.Union[base.String, None]) – Foursquare identifier of the venuedisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.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.Union[base.String, None]) – Contact’s last namedisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – 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, reply_markup: Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardRemove, aiogram.types.force_reply.ForceReply, None] = None, reply: Boolean = True) → aiogram.types.message.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.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound.reply_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 – fill ‘reply_to_message_id’
- Returns
On success, the sent Message is returned.
- Return type
types.Message
-
async
forward(chat_id: Union[Integer, String], disable_notification: Optional[Boolean] = None) → aiogram.types.message.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 channeldisable_notification (
typing.Union[base.Boolean, None]) – Sends the message silently. Users will receive a notification with no sound
- Returns
On success, the sent Message is returned
- Return type
types.Message
-
async
edit_text(text: String, parse_mode: Optional[String] = None, disable_web_page_preview: Optional[Boolean] = None, reply_markup: Optional[aiogram.types.inline_keyboard.InlineKeyboardMarkup] = None) → Union[aiogram.types.message.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.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.disable_web_page_preview (
typing.Union[base.Boolean, None]) – Disables link previews for links in this messagereply_markup (
typing.Union[types.InlineKeyboardMarkup, None]) – 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_caption(caption: String, parse_mode: Optional[String] = None, reply_markup: Optional[aiogram.types.inline_keyboard.InlineKeyboardMarkup] = None) → Union[aiogram.types.message.Message, Boolean][source]¶ 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.Union[base.String, None]) – New caption of the messageparse_mode (
typing.Union[base.String, None]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.reply_markup (
typing.Union[types.InlineKeyboardMarkup, None]) – 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: aiogram.types.input_media.InputMedia, reply_markup: Optional[aiogram.types.inline_keyboard.InlineKeyboardMarkup] = None) → Union[aiogram.types.message.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.Union[types.InlineKeyboardMarkup, None]) – 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[aiogram.types.inline_keyboard.InlineKeyboardMarkup] = None) → Union[aiogram.types.message.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.Union[types.InlineKeyboardMarkup, None]) – 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[aiogram.types.message.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[aiogram.types.inline_keyboard.InlineKeyboardMarkup] = None) → Union[aiogram.types.message.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.Union[types.InlineKeyboardMarkup, None]) – 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[aiogram.types.inline_keyboard.InlineKeyboardMarkup] = None) → Union[aiogram.types.message.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.Union[types.InlineKeyboardMarkup, None]) – 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 pin a message in a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Source: https://core.telegram.org/bots/api#pinchatmessage
- Parameters
disable_notification (
typing.Union[base.Boolean, None]) – 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
ContentType¶
-
class
aiogram.types.message.ContentType[source]¶ Bases:
aiogram.utils.helper.HelperList 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
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:
aiogram.utils.helper.HelperList 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
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